-
Notifications
You must be signed in to change notification settings - Fork 186
docs(api, docs): port Python API documentation to mkdocs #20121
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
base: edge
Are you sure you want to change the base?
Conversation
| display_color: An optional display color for the liquid. | ||
| .. versionadded:: 2.14 | ||
| *New in version 2.14* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I'm assuming mkdocs doesn't support as many of these annotations as sphinx, and that's why you had to change it to English text?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's right. I think nothing is lost in this change. Syntactically, I could never remember the exact Sphinx incantation for these. Semantically, their only target was to become human-readable messages — they were never collated or cross-referenced or anything like that. So here I made the human-readable message directly.
It also has allowed for a little more flexibility. We had some awkward messages of the sort Changed in version 2.x: Removed foo. and now we can just say Removed in version 2.x: Foo.
| """Represents a Flex or OT-2 trash bin. | ||
| See :py:meth:`.ProtocolContext.load_trash_bin`. | ||
| See [`load_trash_bin()`][opentrons.protocol_api.ProtocolContext.load_trash_bin]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. This prompt did great work.
convert this docstring from sphinx-style to google-style. keep all wording exact. replace rst formatting with markdown. replace :ref:, :py:meth:, and :py:obj: crossreferences with markdown autoref style links, for example [
transfer()][opentrons.protocol_api.InstrumentContext.transfer]. the link text for methods should have trailing parentheses, like transfer(), and the link text for other objects should not. when hard wrapping a paragraph or continuing an argument definition past one line, always indent the second and subsequent lines by one level (four spaces) more than the first line. replace RST versionadded and versionchanged statements with italic text saying "New in version…" or "Changed in version…" convert rst admonitions to Material for markdown style admonitions, for example beginning with "!!! note" and indenting all admonition content by one additional level.
And mkdocs was good at raising build warnings if links went to nonexistent targets. I cleaned those up by hand.
| until the pipette is full. On API levels at or above 2.16, no liquid | ||
| will be aspirated. | ||
| location: | ||
| Tells the robot where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the other reviewers: Try adding ?w=1 to the Github URL to ignore whitespace changes (so this file would be https://github.com/Opentrons/opentrons/pull/20121/files?w=1#diff-6811e2f4d45b8d159abed031a1b00c50e69ecc5aa7d8e19a674527fb4be3298c ).
But @ecormany: Did you deliberately have to re-wrap these lines for mkdocs? Why is the linebreak so strange-looking here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of necessary rewrapping did happen, although this one is admittedly peculiar.
A lot of our old sphinx docstrings had extra indentation, with definitions for things like :param my_super_long_cool_parameter_name: indented by 30+ spaces when exactly 4 would have done.
Mkdocs is very strict on having exactly 4 spaces between Args: and the start of each arg definition, and another 4 spaces for any subsequent lines of the definition. Markdown requires that lists not be further indented, while Sphinx requires that they do.
Ultimately, what matters is that these files 1. output correctly and 2. pass black. Anything else is bonus.
|
Thoughts in the for of a PR, felt like the clearest way #20227 |

Overview
This PR ports the entire Python Protocol API documentation from Sphinx to mkdocs.
Test Plan and Hands on Testing
Sandbox
Changelog
The overall process for building the new site was to run LLM conversion of RST to markdown, inspect the results, and iterate until the new mkdocs site accurately reflected all the content in the
edgesandbox.The commit log for this PR tells a more complete story of the process for conversion.
What this PR touches
/docs/python-api/mkdocs project./docs/that control our top-level docs build./docs/mkdocs.ymlincludes the new project./api/src/opentrons/protocol_api/directory for changes when runningmake serve, so if you're editing docstrings you can see the changes automatically.docs.opentrons.com/v2/...URLs.mkdocs servebug./api/src/opentrons/to work with markdown parsing and the new API reference. There should be no code changes except at the whim ofblackformatting.What this means for others
transfer()is#opentrons.protocol_api.InstrumentContext.transfer. Because we use the autorefs plugin for mkdocs, you can use a reference-style markdown link to any unique header anywhere in our documentation (including in publications "outside of" the API docs). So the link totransfer()should look likeInstrumentContext.transfer()if it feels relevant.To do before deployment
new_prefixes) and I've wanted to get rid of them forever. Moving fromdocs.opentrons.com/v2/todocs.opentrons.com/python-api/gives us an opportunity to change these filenames (and this PR does).site/v2/directory at all.[email protected]in a follow-up PRTo do after deployment
/api/docs/v2//api/docs/source for archived sites.Review requests
Thank you all for wading in to review a massive PR.
makesure that my changes touvsetup and docs build are cromulent.Risk assessment
Medium. Touches every single Python API docstring. Updates docs build process.