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

Merged
merged 153 commits into from
Nov 14, 2024
Merged

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: -> see docs: script to convert HTML manual pages to markdown #4620
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 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
@echoix echoix removed the module label Nov 5, 2024
@github-actions github-actions bot added raster Related to raster data processing module labels Nov 5, 2024
include/Make/Html.make Outdated Show resolved Hide resolved
include/Make/Html.make Show resolved Hide resolved
@echoix
Copy link
Member

echoix commented Nov 5, 2024

I was about to approve, but did a quick other check. There's two things that stood out.

Co-authored-by: Edouard Choinière <[email protected]>
echoix
echoix previously approved these changes Nov 7, 2024
@wenzeslaus
Copy link
Member

I get an error with !ENV:

... > make build-mkdocs

MkDocs encountered as error parsing the configuration file: could not determine a constructor for the tag '!ENV'
  in ".../dist.x86_64-pc-linux-gnu/docs/mkdocs/mkdocs.yml", line 2, column 12
make: *** [Makefile:247: build-mkdocs] Error 1

After deleting !ENV from the referenced file:

... > make build-mkdocs
ERROR   -  Config value: 'theme'. Error: Unrecognised theme name: 'material'. The available installed themes are: mkdocs, readthedocs 
ERROR   -  Config value: 'markdown_extensions'. Error: Failed loading extension "pymdownx.details". 
ERROR   -  Config value: 'plugins'. Error: The "glightbox" plugin is not installed 

Aborted with 3 Configuration Errors!
make: *** [Makefile:247: build-mkdocs] Error 1

@landam
Copy link
Member Author

landam commented Nov 8, 2024

I get an error with !ENV:

Environmental variables are supported by mkdocs: https://www.mkdocs.org/user-guide/configuration/#environment-variables

@wenzeslaus Which version of mkdocs do you have?

@landam
Copy link
Member Author

landam commented Nov 8, 2024

... > make build-mkdocs
ERROR - Config value: 'theme'. Error: Unrecognised theme name: 'material'. The available installed themes are: mkdocs, readthedocs
ERROR - Config value: 'markdown_extensions'. Error: Failed loading extension "pymdownx.details".
ERROR - Config value: 'plugins'. Error: The "glightbox" plugin is not installed

please install requirements: man/mkdocs/requirements.txt

See How To, step 1.

@landam
Copy link
Member Author

landam commented Nov 8, 2024

@wenzeslaus Which version of mkdocs do you have?

Probably you have to install https://github.com/waylan/pyyaml-env-tag

@landam
Copy link
Member Author

landam commented Nov 8, 2024

@wenzeslaus Which version of mkdocs do you have?

Probably you have to install https://github.com/waylan/pyyaml-env-tag

If so, we have to update requirements file accordingly. Let us now.

@wenzeslaus
Copy link
Member

I used the requirements file. I have mkdocs 1.1.2. I also added pyyaml-env-tag and reinstalled. I will try to trash everything and start over, but I think I'm still the three mkdocs plugins.

@wenzeslaus
Copy link
Member

Thanks. Starting from scratch with the pyyaml-env-tag package helped. The result (for core repo) looks great!

Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates a great minimal working product (assuming a conversion is done on the side). It does not break the current HTML doc build. while there is a lot of places to improve, we can work on them as PRs against main.

I have only the 2-3 comments about dependencies.

I would be also curious to see a list of special cases you encountered, i.e., what special pages we have. It is sort of hard to keep track. We have the standard options table, intro pages, family, topic and keyword lists, anything else?

man/mkdocs/requirements.txt Outdated Show resolved Hide resolved
REQUIREMENTS.md Outdated Show resolved Hide resolved
@landam
Copy link
Member Author

landam commented Nov 10, 2024

Thanks. Starting from scratch with the pyyaml-env-tag package helped. The result (for core repo) looks great!

Ok, requirements file updated in d45c0b6

@neteler
Copy link
Member

neteler commented Nov 13, 2024

@landam Overall it looks good to me, thanks for your hard work!

One thing I don't understand yet: if we keep both HTML and MD in parallel for a short period, how to deal with the comment parts as seen in 6743f1a? Should this now be activated in the PR?

@landam
Copy link
Member Author

landam commented Nov 14, 2024

One thing I don't understand yet: if we keep both HTML and MD in parallel for a short period, how to deal with the comment parts as seen in 6743f1a? Should this now be activated in the PR?

@neteler No, otherwise the GRASS compilation fails (and breaks CI) since there are no MD files in repo. It can be activated in #4620 or in follow-up PR which adds generated MD files to git.

Copy link
Member

@neteler neteler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on Fedora 40, the result, i.e. the generated manual pages based on markdown look great!

Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the dependencies. I tested the previous version as discussed in my previous review.

@landam landam merged commit 346c8a2 into OSGeo:main Nov 14, 2024
27 checks passed
@landam landam deleted the markdown_docs branch November 14, 2024 15:58
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 libraries module Python Related code is in Python raster Related to raster data processing
Projects
Development

Successfully merging this pull request may close these issues.

5 participants