Skip to content
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

docs: Generate manual from markdown using mkdocs #3849

Open
wants to merge 145 commits into
base: main
Choose a base branch
from

Conversation

landam
Copy link
Member

@landam landam commented Jun 16, 2024

Goal

Build user manual from Markdown using mkdocs

image

How to test

  1. Install requirements, see man/mkdocs/requirements.txt
  2. Create file /tmp/code.lua:
function CodeBlock (cb)
    return pandoc.RawBlock('markdown', '```bash\n' .. cb.text .. '\n```\n')
end
  1. Convert HTML files to Markdown:
for f in `find . -name *.html`; do echo $f; cat $f | sed 's#<div class="code"><pre>#<pre><code>#g' | sed 's#</pre></div>#</code></pre>#g' | pandoc --from=html --to=markdown -t gfm --lua-filter /tmp/code.lua > ${f%%.html}.md;done
  1. Uncomment parts commented in 6743f1a
  2. Recompile GRASS (make distclean; ./configure ...; make)
  3. Build documentation from markdown files: (cd man; make build-mkdocs)
  4. Open dist.x86_64-pc-linux-gnu/docs/mkdocs/site/index.html in web browser

Tasks

Critical:

  • fix CI
  • clean-up mkmarkdown.py
  • man : integrate changes from main
  • separate makefile rules (Markdown.make, MarkdownRules.make) ?
  • make install
  • fix gui/script/ compilation
  • fix compilation issue in raster
  • fix compilation issue in man
  • fix segfault in --md-description
  • fix code blocks
  • fix commit link

Important:

  • implement build_md.py and indices
  • solve warnings generated by mkdocs
  • add missing meta page comments to MD files (as YAML metadata block)
  • consider to keep supporting HTML in g.extension for the addons
  • parser_standard_options: choose formatting than table
  • index: choose better formatting than table
  • replace html with md in links
  • remove toc-related code from mkmarkdown.py and change mkdocs style to show page-related TOC
  • fix "## DESCRIPTION" appearance from keyword list
  • logo points to index.html
  • site_name to "GRASS GIS 8.5.0dev Reference Manual"
  • fix menu items
  • implement parser_standard_options
  • implement manual_gallery
  • use theme footer

Nice to have:

Tasks before merge

  • rebase main and regenerate MD files from HTML once again

Tasks after merge(?)

  • remove rest-related scripts
  • generate man from markdown
  • remove HTML-based documentation and clean-up scripts

@landam landam marked this pull request as draft June 16, 2024 13:28
@landam landam self-assigned this Jun 16, 2024
@landam landam added the docs label Jun 16, 2024
@landam landam added this to the 8.5.0 milestone Jun 16, 2024
@github-actions github-actions bot added windows Microsoft Windows specific GUI wxGUI related vector Related to vector data processing raster Related to raster data processing temporal Related to temporal data processing Python Related code is in Python database Related to database management libraries module general display imagery tests Related to Test Suite raster3d misc labels Jun 16, 2024
utils/mkhtml.py Outdated Show resolved Hide resolved
utils/mkhtml.py Outdated Show resolved Hide resolved
utils/mkhtml.py Outdated Show resolved Hide resolved
landam and others added 4 commits October 24, 2024 10:41
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
utils/mkdocs.py Dismissed Show dismissed Hide dismissed
utils/mkdocs.py Fixed Show fixed Hide fixed
utils/mkdocs.py Dismissed Show dismissed Hide dismissed
@neteler
Copy link
Member

neteler commented Oct 26, 2024

(using prettier on the HTML files generated from MD ( npx prettier --print-width 80 -w *.html) I have found some remove leftover HTML code in the MD part: fixed in ac5e963 and a1fc15e)

@neteler
Copy link
Member

neteler commented Oct 26, 2024

In total, 693 HTML files are generated in dist.x86_64-pc-linux-gnu/docs/mkdocs/site/.

Only 3 files now still contain errors (excellent result!):

i.zc.html
[error] i.zc.html: SyntaxError: Opening tag "meta" not terminated. (9:9)
[error]    7 |       <meta name="viewport" content="width=device-width,initial-scale=1">
[error]    8 |       
[error] >  9 |         <meta name="description" content="Zero-crossing "edge detection" raster function for image processing.">
[error]      |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]   10 |       
[error]   11 |       
[error]   12 |       

-> quotes in quotes issue

r.patch.html
[error] r.patch.html: SyntaxError: Opening tag "meta" not terminated. (9:9)
[error]    7 |       <meta name="viewport" content="width=device-width,initial-scale=1">
[error]    8 |       
[error] >  9 |         <meta name="description" content="Creates a composite raster map layer by using known category values from one (or more) map layer(s) to fill in areas of "no data" in another map layer.">
[error]      |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]   10 |       
[error]   11 |       
[error]   12 |       

-> also quotes in quotes issue

manual_gallery.html
[error] manual_gallery.html: SyntaxError: Unexpected closing tag "div". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (631:4)
[error]   629 | </p>
[error]   630 |
[error] > 631 | <p></div>
[error]       |    ^^^^^^
[error]   632 | <script id="init-glightbox">const lightbox = GLightbox({"touchNavigation": true, "loop": false, "zoomable": true, "draggable": true, "openEffect": "zoom", "closeEffect": "zoom", "slideEffect": "slide"});
[error]   633 | document$.subscribe(() => { lightbox.reload() });
[error]   634 | </script></body>

-> not sure here where this comes from.

Also raster/r.li/r.li.html suffers from a missing </div>, probably the original HTML file contains a bug (I suppose the header stuff therein should be removed, as seen in other "meta page description" pages).

@neteler
Copy link
Member

neteler commented Oct 26, 2024

I have taken liberty to change the pandoc code in the HOWTO above to generate Github-Flavored Markdown -t gfm.

Example: the table in r.sun.md is now syntactically accepted and readable (just the width needs to be adjusted somehow):

image

Background of supported flavors:

@landam landam marked this pull request as ready for review October 31, 2024 06:46
@landam
Copy link
Member Author

landam commented Oct 31, 2024

I have taken liberty to change the pandoc code in the HOWTO above to generate Github-Flavored Markdown -t gfm.

Great! Please feel free to create new PR for HTML to MD conversion. This PR (changing build system to support mkdocs/MD) is ready for review.

neteler added a commit to neteler/grass that referenced this pull request Oct 31, 2024
Script to convert recursively all .html files to .md (GitHub flavoured Markdown).

(see related OSGeo#3849)
@echoix
Copy link
Member

echoix commented Oct 31, 2024

Looks great to me! What will be the steps needed in regards to grass-addons after that change? Will they work out of the box?

@landam
Copy link
Member Author

landam commented Oct 31, 2024

Looks great to me! What will be the steps needed in regards to grass-addons after that change? Will they work out of the box?

This PR is just an initial step. It adds support for markdown-based documentation in build system. HTML-based documentation is still default.

And yes, we have to convert also Addons documentation to markdown, similarly as done for GRASS core modules, see #4620

Steps:

  1. Merge this PR
  2. Finish & merge docs: script to convert HTML manual pages to markdown #4620
  3. Convert Addons documentation to Markdown
  4. Remove HTML-related rules from build system and HTML files

It would be also nice to remove RST-related code which was introduced in the past and never finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Related code is in C CSS Related code is in CSS docs GUI wxGUI related HTML Related code is in HTML imagery libraries module Python Related code is in Python raster Related to raster data processing windows Microsoft Windows specific
Projects
Development

Successfully merging this pull request may close these issues.

5 participants