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

Switch from mkdocs to mdbook #2847

Closed
wants to merge 6 commits into from

Conversation

not-my-profile
Copy link
Contributor

@not-my-profile not-my-profile commented Feb 13, 2023

In 28c9263 I introduced automatic
linkification of option references in rule documentation,
which automatically converted the following:

## Options

* `namespace-packages`

to:

## Options

* [`namespace-packages`]

[`namespace-packages`]: ../../settings#namespace-packages

While the above is a correct CommonMark1 link definition,
what I was missing was that we used mkdocs for our documentation
generation, which as it turns out uses a non-CommonMark-compliant
Markdown parser, namely Python-Markdown2, which contrary to CommonMark
doesn't support link definitions containing code tags.3
Mkdocs doesn't support CommonMark4.

This commit therefore switches our documentation to use mdbook6
instead, which uses the pulldown-cmark7 CommonMark implementation,
sparing us from having to deal with such parser idiosyncracies.

@charliermarsh
Copy link
Member

Hmm... mdBook is a good tool, and I appreciate the work you put in here, but MkDocs is far more popular in the Python ecosystem and will be more familiar to our users. I'm partial to keeping MkDocs around, even if it requires workarounds for some of its idiosyncrasies.

As the original implementation (markdown.pl) works this way, I see no reason to change. After all, if you need to have code inside a link, you can use a reference name in the second set of brackets. That works in all implementations.

From the linked issue: do you understand what this is describing? The link is broken for me.

@not-my-profile
Copy link
Contributor Author

Yes I understand what's being described. Instead of [`namespace-packages`] we would have to do e.g. [`namespace-packages`][namespace-packages] ... since that however is unnecessarily verbose (we wouldn't want it to show up in the ruff rule output), we'd have to employ a regex hack to automatically perform that substitution.

I am personally not interested in implementing regex hacks for deviations from well-established standards. From a website user standpoint I don't think the tool that generated the website should matter. Also note that if we want to strictly lint our Markdown that is much easier when it is CommonMark-compliant, since that is actually well defined.

@charliermarsh
Copy link
Member

From a website user standpoint I don't think the tool that generated the website should matter.

I agree with this sentence (seems hard to disagree with!), but it's an inaccurate description of the change. Unless I'm mistaken, we're not just using a different tool to _generate _the website -- the entire UI of website itself is changing dramatically, since we're moving from Material to mdBook.

I'd prefer not to change this right now. Maybe we'll change our minds in the future. In the meantime, I'd rather find another solution for doc links. If you don't want to work on that, no worries, I'll figure something out.

@not-my-profile
Copy link
Contributor Author

I think from an UX perspective there is very little difference between mkdocs and mdBooks ... both have a sidebar on the left and a search on top ... they even have the same keyboard shortcut s to search ... though mdBook also lets you navigate to the previous/next page with the arrow keys. I'd say the most notable difference is the color theme ... which could be tweaked if deemed important.

@charliermarsh
Copy link
Member

#2867 is somewhat related, as we need a solution for that too.

In 28c9263 I introduced automatic
linkification of option references in rule documentation,
which automatically converted the following:

    ## Options

    * `namespace-packages`

to:

    ## Options

    * [`namespace-packages`]

    [`namespace-packages`]: ../../settings#namespace-packages

While the above is a correct CommonMark[1] link definition,
what I was missing was that we used mkdocs for our documentation
generation, which as it turns out uses a non-CommonMark-compliant
Markdown parser, namely Python-Markdown[2], which contrary to CommonMark
doesn't support link definitions containing code tags.[3]
Mkdocs doesn't support CommonMark[4][5].

This commit therefore switches our documentation to use mdbook[6]
instead, which uses the pulldown-cmark[7] CommonMark implementation,
sparing us from having to deal with such parser idiosyncracies.

[1]: https://commonmark.org/
[2]: https://github.com/Python-Markdown/markdown/
[3]: Python-Markdown/markdown#280
[4]: mkdocs/mkdocs#361
[5]: mkdocs/mkdocs#1835
[6]: https://github.com/rust-lang/mdBook
[7]: https://github.com/raphlinus/pulldown-cmark
They mess up the heading anchors generated by mdbook.
@not-my-profile
Copy link
Contributor Author

Closing this since you're not interested.

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.

2 participants