-
Notifications
You must be signed in to change notification settings - Fork 4
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
Migrate to mkdocs #81
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #81 +/- ##
==========================================
- Coverage 94.73% 94.73% -0.01%
==========================================
Files 15 15
Lines 1806 1805 -1
==========================================
- Hits 1711 1710 -1
Misses 95 95 ☔ View full report in Codecov by Sentry. |
This comment was marked as resolved.
This comment was marked as resolved.
Thanks for looking into this @thomasmarwitz ! See from https://metalearners.readthedocs.io/en/latest/background.html#x-learner |
@kklein Thanks for pointing that out, looks like I completely missed this. You are right, you don't need to escape subscript anymore. |
Aside from the math and enumeration topic mentioned above, what do you see as hurdles and next steps? |
BTW an alternative to readthedocs could be github pages in combination with https://github.com/jimporter/mike. Disadvantage would be that there is no preview for PRs. Advantage would be that there is no external configuration necessary. |
Sounds interesting! Can we have branch-specific deployments with GitHub-pages? Given our somewhat heavy use of formulas, we rely a lot on rendered docs in PRs. |
I don't know whether branch based deployments can be accomplished out of the box with I just tried out to host the |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
I can totally see that one might want to ask that question. In our case we mostly described the 'contract' of a given method/function in the docstrings, i.e. what a user may provide as input and what they can expect as an output. We don't usually say much about the 'how's. At times, changing the implementation does not change this contract. E.g. one might think of the folllowing:
In this case we used said sphinx feature in order to DRY and reduce the risk of inconsistencies due to redundancy. |
I don't think so, so in this case readthedocs might be more fitting. |
0bcbb39
to
cb6c281
Compare
Thanks for your work @thomasmarwitz ! A couple of observations on the rendered docs:
|
@kklein Thanks for examining the current progress so carefully. I checked each point to see whether there is some way of solving it. I haven't implemented everything as changing all URLs, adjusting all docstrings etc. takes some time.
We can disable the dark and auto-mode as a temporary work-around. The site will then be always displayed in light mode.
Thanks for pointing that out. As it turned out, prettier adjusted the tabwidth in markdown, that's why the version on github was always broken. I found a way to override the tabwidth for markdown with 4.
Fixed, typo in heading.
I have to replace all sphinx-like references with mkdocs / normal links. Just not there yet.
I think, this point needs some discussion. During development, I turned off the When building the documentation in CI, we could execute all notebooks beforehand to ensure everything is up to date and then build the documentation. Executing all notebooks everytime, makes the WDYT? (also @pavelzw as you are a huge fan of the
Appears to be a bug, as a work-around we can remove Headings using "``" to wrap code-like elements. If we use that feature frequently, I can open an issue.
This is also sphinx-specific terminology that I haven't replaced completely with the mkdocs equivalent.
Mkdocs has nice admonition rendering: https://squidfunk.github.io/mkdocs-material/reference/admonitions/#+type:note. In jupyter notebooks, the syntactic sugar to render those admonitions is not (sadly) not available. A solution I found is to refer to the "compiled" html elements directly e.g. <!-- mkdocs note -->
<div class="admonition note">
<p class="admonition-title">Note</p>
<p style="margin-top: 0.6rem">The fact that we have a fixed propensity score for all observations is not true for this dataset, we just use it for illustrational purposes.</p>
</div> This produces a note, similar to sphinx: Again, this is not really pretty. If we find ourselves using that a lot, we can also think about opening an issue to support the more concise markdown syntax.
This is also sphinx-specific terminology that I haven't replaced completely with the mkdocs equivalent.
I found a setting to render the type hints: If we add For a table like display (there are also other display options) like this: The function needs a numpy, google or sphinx docstring: https://mkdocstrings.github.io/python/usage/configuration/docstrings/#docstring_style. There is a tendency that google docstrings has more features coming. The nice thing here is that we don't need this google style or whatever everywhere. One can sprinkle that in if e.g. a param needs some explanation as in the screenshot. In all other cases, the param names and types seem pretty solid. |
I'm afraid this is taking so long - that's mainly because migration all sphinx specific syntax to mkdocs (even in docstrings or jupyter notebooks) takes some time and I can only spend a certain amount of time per week on this. @kklein I'll ping you here explicitly once I've migrated all docstrings and jupyter notebooks. |
I totally second your take that the runtime caused by the execution of the notebooks upon building of the docs is a pain. At the same time, I think that the output of the cells creates a lot of value for a reader of the docs. If we can find a solution which provides the outputs while reducing the amount of time used for docs-building that'd be great. To give you some context: We didn't start off by using jupyter notebooks at all for these code examples. Rather, we executed the corresponding code blocks by hand and mode the code blocks as well as the outputs into rst. This approach clearly has the downside of
Looks great; I think adding |
@kklein I talked w/ @pavelzw about how we could address this. I agree that having outputs is very valuable to the reader. Our idea is:
|
@thomasmarwitz sgtm :) |
Forgot during rebase.
Co-authored-by: Pavel Zwerschke <[email protected]>
This is necessary for prettier not to break math rendering which only works when indented 0 or 4 spaces.
a506cd4
to
ff0a208
Compare
Check via execution count in a bash script.
ff0a208
to
7fbabd5
Compare
Demonstrate how mkdocs-jupyter plugin can be used to execute and render Jupyter Notebooks in a similar way to MyST.
Output: https://metalearners--81.org.readthedocs.build/en/81/
TODO:
background.md
Wait for feature: Add option s.t. overridden members are able to "inherit" docstrings from corresponding members in parent classes mkdocstrings/python#194=> moved to griffe extension: https://github.com/mkdocstrings/griffe-inherited-docstrings (now works with version1.1.1
) TBD: maybe not include in copier template!Look into ruff pydocstyle (replacement to pre-commit-hook docformatter)=> The docs migration is already huge