KEMBAR78
Add tools/rdoc-to-md script by skipkayhil · Pull Request #50870 · rails/rails · GitHub
Skip to content

Conversation

skipkayhil
Copy link
Member

Ref #50759

Generally the idea is:

  • use Prism to parse the file into AST + Comments
  • transform each comment block into plain RDoc (instead of RDoc in a
    comment)
  • use RDoc's ToMarkdown class to get a Markdown representation of the
    comment
  • transform the Markdown representation back into a comment
  • write a new file, skipping the lines that were previously RDoc
    comments and instead inserting the new Markdown comments

A little extra work has to be down for metaprogrammed documentation
because ToMarkdown turns RDoc directives into H1s. So for these cases,
the directive is first split off the top before doing the ToMarkdown
transformation and then added back afterwards.

Generally the idea is:
- use Prism to parse the file into AST + Comments
- transform each comment block into plain RDoc (instead of RDoc in a
  comment)
- use RDoc's ToMarkdown class to get a Markdown representation of the
  comment
- transform the Markdown representation back into a comment
- write a new file, skipping the lines that were previously RDoc
  comments and instead inserting the new Markdown comments

A little extra work has to be down for metaprogrammed documentation
because ToMarkdown turns RDoc directives into H1s. So for these cases,
the directive is first split off the top before doing the ToMarkdown
transformation and then added back afterwards.
@rails-bot rails-bot bot added the actiontext label Jan 25, 2024
@rafaelfranca rafaelfranca merged commit 7763d81 into rails:main Jan 25, 2024
@skipkayhil skipkayhil deleted the hm-add-rdoc-to-md branch January 25, 2024 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants