Skip to content

Documentation: Improve automatically generated documentation (for https://ncusi.github.io/PatchScope)#127

Merged
jnareb merged 9 commits into
mainfrom
documentation
May 17, 2025
Merged

Documentation: Improve automatically generated documentation (for https://ncusi.github.io/PatchScope)#127
jnareb merged 9 commits into
mainfrom
documentation

Conversation

@jnareb
Copy link
Copy Markdown
Member

@jnareb jnareb commented May 17, 2025

To improve CLI documentation, there was switch from mkdocs-typer markdown extension to mkdocs-typer2 plugin. Docstring for CLI entry points were improved or added. Also added introduction to CLI.

Note however that because of what seems to be a bug in mkdocs-typer2, the documentation for diffinsights-web is missing from https://ncusi.github.io/PatchScope/cli/, even though it should have been present.

To improve API documentation, the PatchScope project switched from Sphinx to Numpydoc style docstrings, mainly because there is much better support for Numpydocs style in mkdocstrings-python (Python handler for mkdocstrings).

jnareb added 9 commits April 18, 2025 13:34
The mkdocs-typer plugin hasn't been updated in over a year, and there
have been a number of changes to Typer since then. One important change
is that Typer now has its own documentation generation system via the
`typer <module> utils docs` command. The mkdocs-typer2 plugin simply
leverages that system to generate the documentation for your Typer CLIs.

There were some problems with mkdocs-typer plugin because of the way
the 'typer' library is used in this project, and the workaround worked
only partially:
  bruce-szalwinski/mkdocs-typer#18

Note that mkdocs-typer2 is plugin, while mkdocs-typer was markdown
extension.
The Numpydoc format (https://numpydoc.readthedocs.io/en/latest/format.html)
is much better supported by the mkdocstring-python's Graffle engine
than Sphinx format (https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html).

See for example the Graffle documentation about different docstring
formats: https://mkdocstrings.github.io/griffe/reference/docstrings/
it is detailed for Google-style and Numpydoc, but sparse for
Sphinx-style.

The API documentation was not well rendered for Sphinx style.  It seems
like Sphinx style of docstring is beter supported for reST based
documentation generators, like ReadTheDocs (rather than MkDocs).

The main bulk of converting from Sphinx-style to Numpydoc-style was
done with the help of docconvert (https://github.com/cbillingham/docconvert).
It did require some manual corrections though, mostly about the types
of returned values.
The introduction was borrowed, with some adjustments, from the main
README.md.  For example, hyperlinks to tools documentation were
added.

Also added documentation to for `diffinsights-web` command line tool.
Adjust the docstring so that MkDocs generated HTML documentation
renders correctly.  Without, for example, <placeholder> rendering empty
(now uses the `<placeholder>` instead).
Adjust the doctring for the src/diffannotator/annotate.py file,
and add doctring for the common() function - which is the documentation
of the diff-annotate command as a whole (previously there only
individual subcommands had docstring and were documented).
Note that as not a native English speaker, some of those improvements
may not be entirely correct (especially added articles).

Some of changes in this commit were fixes for the automated docstring
style conversion from Sphinx-style (reST) to Numpydoc-style.
Add the doctring for the common() function - which is the documentation
of the diff-gather-stats command as a whole (previously there only
individual subcommands had docstring, and were documented).
Add the doctring for the main() function, which is the entry function
that implements the diffinsights-web command (diffinsights_web.main).
This is intended to provide description for this CLI command.

Unfortunately, for some reason, event while `typer <module> utils docs`
run just fine and produces expected output, mkdocs-typer2 plugin
does not render documentation for diffinsights-web.  Bug report:
syn54x/mkdocs-typer2#15
@jnareb jnareb self-assigned this May 17, 2025
@jnareb jnareb added the documentation Improvements or additions to documentation label May 17, 2025
@dagshub
Copy link
Copy Markdown

dagshub Bot commented May 17, 2025

@github-actions
Copy link
Copy Markdown

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/diffannotator
   __init__.py00100% 
   annotate.py82313683%52, 75–76, 85, 92, 108–111, 113–115, 117, 446–447, 451–452, 454, 505, 507–509, 511, 513–515, 517–518, 520–522, 631, 634, 637–638, 693, 870, 906, 959–961, 965, 1005, 1086, 1354, 1368–1371, 1373, 1377–1380, 1382, 1562, 1565, 1783, 1785, 1832, 1857–1858, 1967, 1970, 2110–2111, 2113, 2138, 2189–2190, 2209–2210, 2213, 2228, 2243–2244, 2285, 2354, 2365, 2391, 2401, 2403, 2412–2416, 2420–2424, 2426, 2461, 2557, 2571, 2573–2574, 2576–2578, 2580, 2582–2584, 2586–2587, 2589, 2591, 2605, 2608, 2623–2625, 2631, 2644, 2653, 2661, 2664, 2734, 2740, 2742–2743, 2756, 2765–2770, 2884–2885, 2888–2889, 2893, 2938
   config.py50786%55–59, 61, 104
   gather_data.py3445384%61, 87, 91, 93, 101, 106, 108, 121, 129, 162, 240–241, 244–245, 248, 251, 262, 280–286, 318–319, 342–343, 366, 390, 415–416, 618, 622, 655, 790, 803, 805, 808, 812, 814, 852, 882–883, 949, 1001, 1187, 1219–1223, 1227
   generate_patches.py38392%102, 104, 126
   languages.py1011684%178, 181, 184, 187, 190, 194, 225–226, 238, 257, 269, 271–272, 275, 281, 319
   lexer.py29293%102–103
src/diffannotator/utils
   __init__.py00100% 
   git.py4878582%118, 269, 359, 361, 364–365, 367, 369–372, 374–376, 378–380, 385–386, 390, 392–393, 397–399, 401–402, 404–405, 407–408, 410, 532–533, 536, 585, 595, 598–600, 606, 637, 641, 648, 680, 693, 756, 843, 898, 905, 935, 939, 943, 990, 992, 1003, 1008, 1013, 1112–1113, 1175–1177, 1180–1181, 1224, 1228, 1305, 1310, 1312, 1315–1316, 1318, 1391–1392, 1525, 1527, 1555–1556, 1568, 1570, 1587–1588, 1628, 1642
TOTAL187230283% 

Tests Skipped Failures Errors Time
81 8 💤 0 ❌ 0 🔥 9.184s ⏱️

@jnareb jnareb merged commit e819b83 into main May 17, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant