Repository navigation
Convert docs from sphinx to mkdocs - #2140
sydduckworth wants to merge 130 commits into
Conversation
Co-authored-by: Brett Graham <brettgraham@gmail.com>
braingram
left a comment
There was a problem hiding this comment.
Thanks again for working on this. I've gone through most of the configuration changes, the general structure and intersphinx links. I started accumulating comments but realized it will be easier to handle these requests via PR(s) against the source branch. I'm going to submit the comments so they're not lost and open a PR against the source branch.
There was a problem hiding this comment.
In a follow-up PR I think the docs could be improved by:
- replacing the toctree uses with text describing the referenced information
- removing this toctree hook
There was a problem hiding this comment.
Searching for the uses in the docs I find 11 links handled by this plugin (1 for pytest, 1 for stdatamodels, 9 for asdf-standard).
Let's replace the custom extlinks with standard markdown links or simple macros and remove this file.
For the asdf-standard links a macro can be added to the config:
extra:
asdf_standard_docs: https://www.asdf-format.org/projects/asdf-standard/en/latestand links replaced with (for example)
[here]({{ asdf_standard_docs }}/generated/stsci.edu/asdf/unit/quantity-1.1.0.html)
which is more familiar syntax compared to:
{{ asdf_standard('here', 'generated/stsci.edu/asdf/unit/quantity-1.1.0') }}
I could be convinced that even the simple macro isn't worthwhile for 9 links.
There was a problem hiding this comment.
Only advantage of the macro is that it validates the links.
We should consider adding some hook or something that just checks external links.
Also, for asdf-standard mind if I turn on the "Clean URL to HTML" redirect in RTD? That way we can omit the .html on the links which makes the source more compact.
Sorry I missed it earlier. You linked to #2158 but I see now your writeup was actually on #2167 which I didn't find before. I'll look at it now. |
- Renamed to `intersphinx_compat` - Now also exports `std:doc` objects - Refactored into a mkdocs plugin class - Added more configuration options
braingram
left a comment
There was a problem hiding this comment.
Here's the first round of content review. I used gpt6.1 sol to compare old and new docs then reviewed and filtered the findings myself. I'll send you the full report separately.
|
|
||
| ## Creating Files | ||
|
|
||
| --8<-- "README.md:create-file" |
There was a problem hiding this comment.
Something isn't quite right with this snippet. With the PR it's showing a file with ASDF_STANDARD 1.2.0:
https://asdf-website--2140.org.readthedocs.build/projects/asdf/en/2140/overview.html#creating-files
on main it shows a file with ASDF_STANDARD 1.6.0:
https://www.asdf-format.org/projects/asdf/en/latest/asdf/overview.html#creating-files
Would you give this a look and sort out how to restore the contents shown on main?
There was a problem hiding this comment.
In the Sphinx docs it copies a snippet from the readme which is followed by the YAML block with ASDF_STANDARD 1.2.0, but instead of including that part it then has an almost identical YAML block with a few small metadata differences, such as having ASDF_STANDARD 1.6.0.
I got rid of the duplicated code block in overview.md and had it just use the one that's already in the readme. If you want I could update the code block in the readme to match overview.md.
There was a problem hiding this comment.
Can we fix the inventory version here (or elsewhere in the configurate). It currently shows version 0.0.0:
>> head -n 3 site/objects.inv
# Sphinx inventory version 2
# Project: asdf
# Version: 0.0.0
There was a problem hiding this comment.
Probably not related (but not sure where to comment) but the intersphinx inventory also does not list the asdf module.
There was a problem hiding this comment.
Looking at the mkdocstrings code it appears that it doesn't actually set the project version, it's just always 0.0.0. I'm not aware of any way that the version in objects.inv is used by consuming clients, so doesn't seem like a major problem.
There was a problem hiding this comment.
In general the modules in the inventory seem off.
It seems to be adding modules to the inventory if they're imported by another module, even if it's not in the module's __all__, e.g. the inventory contains asdf.lazy_nodes.tagged because asdf.lazy_nodes imports tagged. I guess that's not a huge issue, other than polluting the inventory a bit.
Not sure yet why it's not including the root module though.
There was a problem hiding this comment.
From https://sphobjinv.readthedocs.io/en/stable/syntax.html the version is used in hover over text generation as is the case now on RTD. Here's an example with the docs on main:

There was a problem hiding this comment.
Okay, will try to find a better solution later but for now I've updated the intersphinx_compat hook to populate the inventory package version.
There was a problem hiding this comment.
Oh I figured out the asdf module being missing. That's because it was being overwritten by an asdf std:label object.
There was a problem hiding this comment.
I've updated intersphinx_compat so it will emit a warning if a registered object overwrites an existing object, and (for now) removed the std:label asdf entry. That is one of the few labels that is definitely referenced by several other projects though, so probably need a better solution.
There was a problem hiding this comment.
I actually think I have a solution to this.
Right now Edit: I'm wrong about this I think, but another similar solution may work.intersphinx_compat is appending to the mkdocstrings-python inventory, but I think it should be doable to instead add an entirely new handler from within the hook which would then have its own inventory that wouldn't conflict.
I'll look into that once I'm back in the office after Thanksgiving.
There was a problem hiding this comment.
OKAY, so I actually found a fix for this, although its a bit hacky.
mkdocstrings.Inventory is a dictionary that keys objects by name, but it appears that the dictionary key actually isn't used by mkdocstrings anywhere.
So I just updated the hook to swap the inventory out with a custom subclass that keys by domain:role:name instead. Now all the objects can coexist, and it doesn't seem to have broken anything in the docs themselves 😅
|
|
||
| Raises a warning if the URL for a label doesn't exist in the docs. | ||
|
|
||
| # Docs |
There was a problem hiding this comment.
Something is polluting the doc entry names. See example:
std:doc
api/asdf/config <code class="doc-symbol doc-symbol-module"></code> asdf.config: api/asdf/config.html
The code tag shouldn't be there.
There was a problem hiding this comment.
The entry name comes from the page name, and that is what the module's page name is.
To me the std:doc items for API pages didn't seem that important since realistically I don't see why someone would be referencing those pages via doc rather than py.
There was a problem hiding this comment.
That does indeed seem to come literally from https://github.com/asdf-format/asdf/pull/2140/changes#diff-aed2cba4728ca2741215a681e42c91a87c715e2abb419b26da30b9bb92b312ea or the equivalent for the user API docs. Which I'm a bit puzzled by too.
…sphinx inventory
Updated `intersphinx_compat.py` to emit a warning when an existing object is overwritten.
Description
Closes #2167
towncrierto ingest and output markdown instead of RSTdocs/.hooks/directory which contains custom mkdocs hooks:toctree.py- implements similar functionality to the Sphinxtoctreedirective, although currently limited to a single file. Will hopefully be removed in future PRs as we update the docs structure.strip_doctest_flags.py- finds and removes doctest flags (e.g.# doctest: +SKIP) from code blocks.export_legacy_labels.py- injects Sphinx-style doc labels intoobjects.invto maintain compatibility with downstream projects that reference our docs.docs/.overridesdirectory:main.html- Updates page layout to add announcement banner with links at top and add RTD version integrationpartials/copyright.html- Generates copyright string with current year during buildmacros/- Functions and variables for use in templating viamkdocs-macrostowncrier.py- Adds macro function that runstowncrierto generate a new changelog section with any pending changes and inserts it at the current location (returns an empty string if there are no pending changes).extlink.py- Implements similar functionality to Sphinx'sextlinksplugin by registering new macros that expand to external project URLs. Also implementslinkcheck-like functionality to verify links are valid.Changes to Documentation Structure
api/subtree, which is not part of site navigation. The "User API" and "Developer API" pages then manually link desired API pages._in their path), but we could easily do this for all modules if we wanted"public"filter works formkdocstrings-pythonobjects.invsphinx inventory, but only for thepydomain. This means that any other projects that are using Sphinxstddomain refs to ASDF will need to be updated.*.html -> */)/asdf/* -> /*Changes to Build Process
nox docs -- serveto launch a local docs server which automatically reloads when files are changed.towncrier build --keep.Zensical Compatibility
mkdocs-materialreaches end of life on May 5th, 2027. The intended replacement (for both it and mkdocs as a whole) is Zensical. Zensical is still in early development but is expected to reach 1.0 in November.I've tested building the docs with Zensical. Other than the compatibility issues listed below, everything works:
strip_doctest_flagscan be converted to a Superfences custom formatter, which Zensical supports. For now it's more convenient to leave it as a hook.toctreecan hopefully be removed in the future as we move away from the old Sphinx docs structure.mkdocs-macrosmacro.build_date_utcto define the copyright string in the footer, which Zensical currently doesn't support.copyright.hmldescribing a workaround I found which I confirmed works with Zensical.git-revision-date-localizedplugin isn't supported. Support for it is on Zensical's roadmap and if not this plugin can just be removed.absolute_links: relative_to_docsfor cleaner reference paths that don't depend on the current file (e.g. if we're in a subdirectory it's nicer to write/changelog.mdthan to write../changelog.md). Zensical currently seems to treat these as relative paths instead. It's unclear if this is intentional, a missing feature, or a bug. Worst case, it would be easy to convert the absolute links to relative links.Worth noting that there is also materialx, which is a fork of
mkdocs-materialthat will receive ongoing support. I didn't go with materialx over material initially because materialx is only maintained by a single person, but it is at least an option if we really don't want to use Zensical.AI Disclosure
No AI tools used
Tasks
prekon your machinepyteston your machineno-changelog-entry-needed)changes/:echo "changed something" > changes/<PR#>.<changetype>.rst(see below for change types)docs/pagenews fragment change types...
changes/<PR#>.feature.rst: new featurechanges/<PR#>.bugfix.rst: bug fixchanges/<PR#>.doc.rst: documentation changechanges/<PR#>.removal.rst: deprecation or removal of public APIchanges/<PR#>.general.rst: infrastructure or miscellaneous change