Skip to content

docs: Replace grass-stable URLs by relative URLs #5527

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

wenzeslaus
Copy link
Member

@wenzeslaus wenzeslaus commented Apr 10, 2025

The core and addons doc mostly use absolute paths to refer to each other. However, when the docs are build together, the links may point to a wrong version. This is now even a bigger issue with Sphinx-based Python doc which is more linked from the main doc than it was before.

Having the absolute URLs pointing to grass-stable is still a good solution. It is straightforward. It works locally and when each piece is build separately.

The new script and the build step in CI is done after the two documentations are put together and with anticipation that libpython will be build into it. The replacement is done on Markdown level, so MkDocs will complain that the libpython links are broken, but that does not break the build and hopefully having both MkDocs and Sphinx docs is something to change in the future. No replacements are done for links from libpython, but there are currently none. The only links which are there are relative already.

The core and addons doc mostly use absolute paths to refer to each other. However, when the docs are build together, the links may point to a wrong version. This is now even a bigger issue with Sphinx-based Python doc which is more linked from the main doc than it was before.

Having the absolute URLs pointing to grass-stable is still a good solution. It is straigforward. It works locally and when each piece is build separately.

The new script and the build step in CI is done after the two documentations are put together and with anticipation that libpython will be build into it. The replacement is done on Markdown level, so MkDocs will complain that the libpython links are broken, but that does not break the build and hopefully having both MkDocs and Sphinx docs is something to change in the future. No replacements are done for links from libpython, but there are currently none. The only links which are there are relative already.
The core and addons doc mostly use absolute paths to refer to each other. However, when the docs are build together, the links may point to a wrong version. This is now even a bigger issue with Sphinx-based Python doc which is more linked from the main doc than it was before.

Having the absolute URLs pointing to grass-stable is still a good solution. It is straigforward. It works locally and when each piece is build separately.

The new script and the build step in CI is done after the two documentations are put together and with anticipation that libpython will be build into it. The replacement is done on Markdown level, so MkDocs will complain that the libpython links are broken, but that does not break the build and hopefully having both MkDocs and Sphinx docs is something to change in the future. No replacements are done for links from libpython, but there are currently none. The only links which are there are relative already.
@wenzeslaus
Copy link
Member Author

We need to check here if it actually works in the CI by inspecting the artifact once it's build.

@wenzeslaus wenzeslaus added this to the 8.5.0 milestone Apr 10, 2025
@wenzeslaus wenzeslaus self-assigned this Apr 10, 2025
@github-actions github-actions bot added CI Continuous integration Python Related code is in Python labels Apr 10, 2025
@wenzeslaus wenzeslaus changed the title use relative links in build doc docs: Replace grass-stable URLs by relative URLs Apr 12, 2025
@wenzeslaus
Copy link
Member Author

Examining the artifact, this works well for links from core to libpython (e.g., from Python intro) and to addons (e.g., from r.mapcalc to r.bitpattern). It does not work from addons to core (e.g., v.surf.icw).

Also, the test ./imagery/i.smap/testsuite/test_i_smap.py fails for some reason on Ubuntu.

Even more stuff:

Additionally, we have a lot of versioned URLs to addons in the source code, so these should be eventually replaced by version-less URLs:

- https://grass.osgeo.org/grass8/manuals/addons/r.stream.order.html
+ https://grass.osgeo.org/grass-stable/manuals/addons/r.stream.order.html

Doing the replacement before MkDocs runs means that a lot warnings are produced by MkDocs. I know that ahead of time, but perhaps it is worth revisiting.

Some are hard to fix because libpython is simply added only after MkDocs step (or maybe we can add that ahead of time and thus have the links checked by MkDocs?):

Doc file 'development_intro.md' contains a link 'libpython/index.html', but the target is not found among documentation files.
WARNING -  Doc file 'development_intro.md' contains a link 'libpython/gunittest_testing.html', but the target is not found among documentation files.

Some are fixable if we not only replace the base URL but also the extension:

WARNING -  Doc file 'g.download.project.md' contains a link 'addons/g.proj.all.html', but the target is not found among documentation files. Did you mean 'addons/g.proj.all.md'?
WARNING -  Doc file 'i.gensigset.md' contains a link 'addons/v.transects.html', but the target is not found among documentation files. Did you mean 'addons/v.transects.md'?
WARNING -  Doc file 'i.landsat.toar.md' contains a link 'addons/r.clip.html', but the target is not found among documentation files. Did you mean 'addons/r.clip.md'?

Perhaps even adding index.md for the directories?

INFO    -  Doc file 'development_intro.md' contains an unrecognized relative link 'addons/', it was left as is. Did you mean 'addons/index.md'?

@echoix
Copy link
Member

echoix commented Apr 12, 2025

Usually, for doc builders like this, you have to make the links work with the files you have in the repo (with the advantage that when previewing in GitHub or your IDE, links work correctly), and the doc builder makes sure to have the links work with what it generates.

Then, there's often the option to do url mappings for having some internal/external URLs point to something else or to external/internal URLs. For addons->grass or grass->addons, since it is a different repo, I'm not sure what is best to do. Have full URLs in the source files, but then adjust the docs url mappings to recognize that these URLs can be converted to relative, as they are hosted from the same domain?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous integration Python Related code is in Python
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants