open-source-rover icon indicating copy to clipboard operation
open-source-rover copied to clipboard

Documentation build proof-of-concept using MkDocs

Open sethfischer opened this issue 4 years ago • 6 comments

Documentation build proof-of-concept using MkDocs.

Two MkDocs themes have been investigated:

Preference has been indicated for #360 as it supports versioned documentation.

Documentation demo is hosted at https://osr-demo.readthedocs.io/ (Read the docs)

Todo

The following fixes should be fixed as separate issues and merged before this issue (#317). See Bugs section below for an explanation.

  • [ ] Make GitHub.com links absolute #361
  • [ ] Fix whitespace-only changes to the Markdown documents #362

After this (#317) is merged, and before documentation can be deployed to Read the Docs:

Bugs

There are currently a few bugs in the rendered HTML. However, these can all be fixed with whitespace-only changes to the Markdown documents:

  • Empty lines between paragraphs and lists
  • Empty lines between paragraphs and tables
  • Consistent list indentation
  • Remove leading whitespace from headings and paragraphs

The above changes are compatible with the GitHub flavoured Markdown specification meaning rendering of Markdown on GitHub.com will not be affected.

For links to GitHub directories to work:

  • Make GitHub links absolute

As it turns out, all GitHub links bar one in electrical/README.md are absolute.

Change to GitHub link in electrical/README.md
[the PCB folder](/electrical/pcb/)

should be changed to:

[the PCB folder](https://github.com/nasa-jpl/open-source-rover/tree/master/electrical/pcb)

Requirements

The proof-of-concept was built to the following requirements:

  • no changes to the directory structure of the project
  • allow the documentation to be displayed/used as it currently is on GitHub.com
  • add only a few additional files to the codebase
  • automatic build and deploy

Related issues

This proposal may resolve #106.

sethfischer avatar Jun 22 '21 10:06 sethfischer

I haven't looked through all documentation generated by this but at a first glance it looks really nice. I have a few questions as I'm not familiar with mkdocs much.

  • what is the upkeep for this? Is it auto updated from updates to the Readme docs?
  • does it support release versions? (not necessary, but could be nice to keep legacy versions of the documentation)
  • are there any other changes we'd need to look at making to support this?

ericjunkins avatar Jun 22 '21 16:06 ericjunkins

what is the upkeep for this? Is it auto updated from updates to the Readme docs?

Yes. The built site is auto updated from the Readme docs.

Read the docs has a GitHub webhook to trigger automatic builds. Builds are triggered on push or merge to master.

The proof-of-concept is configured to automatically build on push or merge to sethfischer:mkdocs.

Periodically project maintainers may receive notification from GitHub that dependencies in requirements.txt have a security release available. At a guess this would be a annual task that can be done by someone who has experience with pip.

does it support release versions?

Yes, Read the docs does support release versions which are based on tags.

I agree, versioning is important. I will look at the options and add it to the proof-of-concept.

To make use of versioning we may need to use the MkDocs readthedocs theme. The readthedocs theme is one of two MkDocs built-in themes so moving to that would remove a dependency.

are there any other changes we'd need to look at making to support this?

This is an experiment, the purpose of which is to identify any further changes that may be required. Over the next few months I'll regularly rebase sethfischer:mkdocs off nasa-jpl:master; noting any problems in the description of this issue.

sethfischer avatar Jun 23 '21 09:06 sethfischer

This is really awesome and makes it easier to use for those new to GitHub. Great effort!

Achllle avatar Jul 02 '21 04:07 Achllle

Screenshot of the documentation built with theme Material for MkDocs.

osr-demo readthedocs io_2022-02-20_material_for_mkdocs

sethfischer avatar Feb 20 '22 07:02 sethfischer

Screenshot of the documentation built with theme readthedocs. This theme has version support.

osr-demo readthedocs io_2022-02-20_readthedocs_for_mkdocs

sethfischer avatar Feb 20 '22 08:02 sethfischer

Looks great. Happy to merge whenever you're ready!

Achllle avatar Feb 24 '22 17:02 Achllle

Investigation into hosting versioned MkDocs on GitHub Pages. This is a possible alternative to MkDocs hosted on readthedocs.

  • Need to use the MkDocs Material theme. See https://github.com/nasa-jpl/open-source-rover/issues/317#issuecomment-1046182232 above for screenshot.
  • Use mike which is a utility for deploying multiple versions of a MkDocs-powered docs to a Git branch.

Notes:

  • Relative GitHub links would still need to be converted to absolute. This is due to GitHub Pages being served from http(s)://<organization>.github.io/<repository> rather than http(s)://github.com/<organization>/<repository>.
  • No automated deploy out-of-the-box. But this could possibly be added at a later date with a GitHub Action. Without a GitHub Action a maintainer will need to manually build the docs.

sethfischer avatar Oct 15 '22 02:10 sethfischer

Comparison of hosting options: Read the Docs vs. GitHub Pages.

Feature Read the Docs GitHub Pages
Automated deploy Yes Manual action for maintainer (or GitHub Action).
Domain example https://<project>.readthedocs.io https://<organization>.github.io/<repository>
Theme MkDocs Read the Docs MkDocs Material
Versioned Yes Yes
Requires absolute links to GitHub files + folders Yes Yes
Configuration (one off) Maintainer creates a RTD account and links it to GitHub. Maintainer configures GitHub pages.
Dependencies + mike + GitHub Action (optional)

The GitHub Pages option will have a higher maintenance burden due to the additional dependency and GitHub action.

sethfischer avatar Oct 15 '22 03:10 sethfischer

Thanks for the thorough analysis! I'm happy to help create the Github action if necessary, but if the options are otherwise equivalent in your opinion, I'm fine with read the docs. I do like that I don't need an account for read the docs though with the pages option.

Achllle avatar Oct 15 '22 21:10 Achllle

I think I asked this already, but can you remind me why you couldn't get relative links to work? The readthedocs documentation and github pages documentation are pretty explicit in saying that it should work.

Achllle avatar Oct 15 '22 21:10 Achllle

I forgot I set this up in the past already. This is my Github action:

name: docs

on:
  push:
    branches:
      - "main"
  workflow_dispatch:

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Build and push docs
        uses: athackst/[email protected]
        with:
          publish_branch: gh-pages-main
          edit_uri: edit/main

It uses MkDocs Simple Plugin and support relative links.

Achllle avatar Oct 15 '22 21:10 Achllle

I think I asked this already, but can you remind me why you couldn't get relative links to work? The readthedocs documentation and github pages documentation are pretty explicit in saying that it should work.

@Achllle As you state, links between documentation pages can and should be relative.

By GitHub relative links I'm referring to links in the documentation that point to the GitHub app.

An example is #361. /electrical/pcb/ is a link to a GitHub app page, which is a directory listing.

They can be found in [the PCB folder](/electrical/pcb/)

On GitHub this resolves to: https://github.com/nasa-jpl/open-source-rover/tree/master/electrical/pcb In the built documentation this resolves to: https://osr-demo.readthedocs.io/electrical/pcb/ which does not exist[^1].

so the suggested change is:

They can be found in [the PCB folder](https://github.com/nasa-jpl/open-source-rover/tree/master/electrical/pcb).

[^1]: See the link the PCB folder on https://osr-demo.readthedocs.io/en/latest/electrical/index.html

sethfischer avatar Oct 16 '22 03:10 sethfischer

I'm fine with read the docs. I do like that I don't need an account for read the docs though with the pages option.

@Achllle I think GitHub Pages is a good way to go. If you agree I will:

  1. Change the theme to MkDocs Material
  2. Add mike and do some local testing to ensure versioned documentation is working.

Both of the above are requirements for having versioned documentation hosted on GitHub Pages.

  1. Then I will hand over to a maintainer for deploying to GitHub Pages.

sethfischer avatar Oct 16 '22 03:10 sethfischer

I see. It's odd to me that there's no out of the box support for this seemingly common scenario. I found https://github.com/mkdocs/mkdocs/issues/1619 which explains why it doesn't work.

To me, replacing relative links unfortunately is a show stopper. It means that someone browsing on a fork or commit will be taken away from that fork or commit without any warning. That can lead to confusion and waste of time. In addition, we support multiple versions of ROS and with the upcoming new rover design, we'll need even more pages. Finally, it means that we have to educate contributors that they need to use absolute links in some cases and relative links in others, which I don't love because it means increasing the barrier to contribution.

I wonder if it can be easily achieved with a macro or simple mkdocs plugin. Whenever a relative link to a non-page/non-image is detected, we replace it with an absolute link at generation time, so that we have the best of both worlds.

Achllle avatar Oct 16 '22 05:10 Achllle

Unfortunately I can't see a solution to this. I have a few ideas but they very quickly snowball into quite big changes which will not meet the following requirements defined when the issue was opened:

  • no changes to the directory structure of the project
  • allow the documentation to be displayed/used as it currently is on GitHub.com

I agree with @Achllle in that we do not want to introduce any confusion in the documentation. Especially as builders are, and have been, very happy with the presentation of the current documentation.

As stated above, the justification of introducing built documentation was based on minimal changes to the project and no changes to the documentation workflow. We have now established this is not the case. If people are in agreement I suggest we close this issue and related pull requests.

sethfischer avatar Oct 16 '22 06:10 sethfischer

I've reviewed comment 1279904259 above and also taken another look at jimporter/mike.

The choice of hosting platform comes down to the following pairings to support versioned documentation:

  1. If we want to host on Read the Docs we must use the theme MkDocs Read the Docs.
  2. If we want to host on GitHub pages we must use the theme MkDocs Material.

See earlier comments in this issue for screenshots of each. Other than that that all else will be equivalent.

sethfischer avatar Mar 21 '23 07:03 sethfischer

No strong preference here. I like GitHub actions and can help set them up for automated deployments but I see that there's a dependency for it. ReadTheDocs is also frequently used so to me either are sound choices. I would pick what is easiest to maintain + explain to others such that it "just works".

Achllle avatar Mar 22 '23 21:03 Achllle