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

Remove some MkDocs log noise #1815

Merged
merged 9 commits into from
Dec 12, 2023
Merged

Conversation

StevenMaude
Copy link
Contributor

@StevenMaude StevenMaude commented Dec 7, 2023

The MkDocs logs when serving or building the documentation are noisy, and are at least a screenful of information for me on my display configuration.

This hides information that might actually be useful to people when working on the documentation: new problems that might have been introduced when editing aren't obvious.

This PR reduces, but does not entirely remove, the noise by:

  • fixing up some of the issues associated with the logs; some links were actually broken in the OpenSAFELY documentation site
  • removing some of the false positives by configuring MkDocs options to exclude certain paths from checks

Other notes

  • The logs are now much cleaner when using just docs-serve --clean — this takes account of the exclude_docs option I've configured in mkdocs.yml. This excludes the includes/ directory, which is a source of multiple false positives. Perhaps we should make --clean the default in just docs-serve? (Sometimes people might want to preview excluded documents, such as a drafts/ directory, which is why this is not the default MkDocs behaviour.)
  • There's a quirk where some URLs work in the ehrQL documentation preview, but not OpenSAFELY's documentation. The difference is that the ehrQL preview uses paths to pages like /how-to/…, while the OpenSAFELY site has paths like /ehrql/how-to/…. Because of this, some links — either from absolute paths or from relative paths that reach the URL root — work in the ehrQL preview, but are broken on the OpenSAFELY site. I'm not sure why the OpenSAFELY link check doesn't catch these. I opened an issue for restructuring the ehrQL preview.
  • The OpenSAFELY documentation site has the same problem with including the ehrQL includes/ as accessible pages. Because we still have the quirk of having to duplicate our configuration, we should configure it there too.
  • The remaining issues are primarily around how relative paths are automatically generated in the Python code inside ehrql/docs. This might be a little bit trickier to get right, so I've opened an issue to document the problem, and it can be a separate PR.

Copy link

cloudflare-workers-and-pages bot commented Dec 7, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 19ca009
Status: ✅  Deploy successful!
Preview URL: https://935bac71.databuilder.pages.dev
Branch Preview URL: https://steve-remove-some-mkdocs-log.databuilder.pages.dev

View logs

@StevenMaude StevenMaude marked this pull request as ready for review December 7, 2023 13:29
@StevenMaude
Copy link
Contributor Author

Checked the links by hand in the ehrQL preview, and a preview of the OpenSAFELY documentation site that incorporates this ehrQL branch.

Copy link
Contributor

@Jongmassey Jongmassey left a comment

Choose a reason for hiding this comment

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

Looks good AFAICT

Copy link
Member

@iaindillingham iaindillingham left a comment

Choose a reason for hiding this comment

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

🚀

(Yes, that doesn't sound like a contradiction at all.)

Files in the top-level `/includes/` directory are actually included by
the snippet support in pymdown-extensions, instead of directly included.

This exclusion is to:

* prevent the `includes/` directory from being included as built HTML
  pages themselves (which is in addition to their use as snippets in
  other built HTML pages)
* allows suppressing of MkDocs warnings from these pages for `mkdocs build` and
  `mkdocs serve --clean`. (These warnings are because the relative links in the
  `includes/` source don't point to their intended actual links in the
  source directory, but they do when included as snippets.)

The preceding `/` in `/includes/` is to exclude only the top-level
`/includes/` directory to keep the exclusion rule specific; the option
uses a `.gitignore` pattern format.

See https://www.mkdocs.org/user-guide/configuration/#exclude_docs
This suppresses more MkDocs log noise.

These pages are intended to be included, but are currently listed on a
index-style page that gives more context.
Some of the existing links work in the ehrQL docs build,
but not the main OpenSAFELY documentation site.

This is because:

* some of the existing links are either absolute links to the URL root,
  or relative paths that go the URL root, before descending
* the ehrQL docs build preview has all the content at the
  URL root, and not, like the OpenSAFELY documentation site, in
  `/ehrql/`, so there's a mismatch of the depth of URLs there

It would be good to make the two sites consistent: that is, make the
ehrQL preview actually have URLs like: `/ehrql/how-to/…` instead of
`/how-to/…` — it would remove the possibility for this kind of broken
link.
This does not change the rendering, but does remove the MkDocs warnings.

It uses a `.md` suffix, so MkDocs can find the file, and adjusts the
relative path.
* Use code formatting
* Remove rogue trailing quote
This link is broken in two ways:

* it's an absolute link, which doesn't work in the OpenSAFELY
  documentation (but does in the ehrQL preview)
* it always links to the `core` schema, whereas the intent is
  probably to keep the link to the same schema — this appears for `tpp`,
  for example
@StevenMaude StevenMaude force-pushed the steve/remove-some-mkdocs-log-noise branch from ba74727 to 19ca009 Compare December 12, 2023 11:26
@StevenMaude
Copy link
Contributor Author

I've left the just docs-serve command as is; just docs-serve --clean will give you cleaner logs without as many lines informing you of deliberate exclusions.

@StevenMaude StevenMaude merged commit 8335000 into main Dec 12, 2023
8 checks passed
@StevenMaude StevenMaude deleted the steve/remove-some-mkdocs-log-noise branch December 12, 2023 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants