Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on m2r (use MyST instead) #6

Merged
merged 4 commits into from
Oct 11, 2022
Merged

Conversation

luator
Copy link
Member

@luator luator commented Oct 5, 2022

Description

We can use MyST to include the README.md into a rst file, thus getting rid of the dependency on m2r (which provides mdinclude that was used before).

As this makes different include commands necessary, depending on the format of the README ("md" or "rst"), move the code for handling the README to its own function and generate the appropriate include directive there. This is then added to index.rst using a template variable.

Apply equivalent changes for including the license file. Since the license is always expected to be plain text, no format distinction is needed here. Simply using standard .. include:: instead of .. mdinclude:: results in the same output, at least for our BSD license files.

Note that there is a minor difference to using m2r, the section headers of the included README are one level lower now (left is with m2r, right with MyST):
breathing_cat_Screenshot_20221005_110838_compare_mdinclude_to_myst_include_markdown
However, I don't think this is a problem. Apart from this the result looks exactly the same.

Closes #2.

How I Tested

By building the documentation for blmc_drivers (which has a README.md) and robot_fingers (which has README.rst).

I fulfilled the following requirements

  • All new code is formatted according to our style guide (for C++ run clang-format, for Python, run flake8 and fix all warnings).
  • All new functions/classes are documented and existing documentation is updated according to changes.
  • No commented code from testing/debugging is kept (unless there is a good reason to keep it).

No need for additional dependencies here, the License is anyway expected
to be plain text.
NOTE: This breaks support for READMEs in rst format!
When using MyST to include Markdown-READMEs a different include command
is needed in case of a README in rst format.  Therefore move the code
for searching and copying the README into a function and construct the
include command there, depending on the format of the file.
This is then added to the index.rst using a template variable.

Move the equivalent code for the license file to its own function in the
same way, to be consistent.
It is not used anymore.
@luator
Copy link
Member Author

luator commented Oct 11, 2022

@MaximilienNaveau Sorry, I forgot to add you as reviewer...

Copy link

@MaximilienNaveau MaximilienNaveau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice work!
Thanks!

def _copy_readme(source_dir: Path, destination_dir: Path) -> str:
"""Searches for a README in the source and copies it to the destination directory .

Searches for a "README.md" or "README.rst" (case-insensitive) in the source

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also look for "README" and assume markdown

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense but I think it will need a bit of rewrite. I'll create an issue to add this in a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#7

@luator luator merged commit ff0f206 into master Oct 11, 2022
@luator luator deleted the fwidmaier/rm_m2r branch October 11, 2022 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace m2r and recommonmark with MyST
2 participants