Skip to content

Documentation: Improve process for MkDocs-based documentation#129

Merged
jnareb merged 5 commits into
mainfrom
documentation
May 29, 2025
Merged

Documentation: Improve process for MkDocs-based documentation#129
jnareb merged 5 commits into
mainfrom
documentation

Conversation

@jnareb
Copy link
Copy Markdown
Member

@jnareb jnareb commented May 29, 2025

Fix a few warnings from mkdocs build / mkdocs serve, namely the use of deprecated 'uslugify' instead of configurable 'slugify', and 'watch' configuration added under 'mkdocstrings' plugin instead of being (as it should) a global option for mkdocs itself.

Fix 'include-markdown' directive in annotation_process.md (also replacing it with 'include' directive), so that example line callback function is included properly, inside code block.

Rewrite links in included (via 'include-markdown') README.md Markdown files with custom hook, so that they lead either to documentation page, or to rendering of a file in question in project's GitHub.

While at it, replace HTTP links with HTTPS ones, where possible.

jnareb added 5 commits May 20, 2025 14:45
Get's rid of the following DeprecationWarning: 'uslugify' is deprecated.
  'uslugify' is deprecated in favor of the configurable 'slugify' function.
  See documentation for more info.

The configuration of 'slugify' is borrowed from PyMdown Extensions FAQ:
https://facelessuser.github.io/pymdown-extensions/faq/#function-references-in-yaml

The Python-Markdown 'toc' (Table of Contents) extension is documented at:
https://python-markdown.github.io/extensions/toc/
The 'watch' configuration option is a global config
https://www.mkdocs.org/user-guide/configuration/#watch
not configuration of 'mkdocstrings' plugin (even though
we want to watch 'src/' to automatically re-run
 mkdocstrings)'.
The 'start' and 'end' options define delimiters that marks the
beginning and end of the contents to include, _not_ delimiters
that will be put around included contents.

Use 'include' instead of 'include-markdown', because the file
being included is Python code, not Markdown document.
Using README.md files to create basis of the MkDocs-based project
documentation with the help of mkdocs-include-markdown-plugin has one
disadvantage: links to other READMEs and other files from those
README.md files work for them when browsed on GitHub, but lead to 404
within the generated documentation.  The 'rewrite-relative-urls' option
helps, but is not a panacea.

For example, notebooks/README.md file contains link to main README.md.
This gets turned into ../README.md when include-markdown in notebooks.md
gets processed.  This needs to be adjusted to point to index.md (which
includes README.md).

Those README.md files also contain links to directories and non-Markdown
files.  Those needs to be turned in full GitHub URLs to directory (tree)
or file (blob) in question.

.
There is 'mkdocs-redirects' plugin to create page redirects, but it is
about actually creating a new page where an old page was that redirects
to the new page using JavaScript redirect.  It is intended for moved
and renamed pages, rather than for fixing links.
  https://github.com/mkdocs/mkdocs-redirects

Therefore a MkDocs hook was created, hooking `on_page_markdown` event,
and doing search and replace on links (using regular expressions).
The script with the hook is currently at scripts/my_hooks.py.
  https://www.mkdocs.org/user-guide/configuration/#hooks
  https://www.mkdocs.org/dev-guide/plugins/#on_page_markdown

While at it, the hook also checks for non HTTPS external links.
@jnareb jnareb self-assigned this May 29, 2025
@jnareb jnareb added documentation Improvements or additions to documentation enhancement New feature or request labels May 29, 2025
@dagshub
Copy link
Copy Markdown

dagshub Bot commented May 29, 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 🔥 10.995s ⏱️

@jnareb jnareb merged commit f21d8df into main May 29, 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 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant