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

Add mdbook docs page #11849

Merged
merged 6 commits into from
Dec 17, 2024
Merged

Add mdbook docs page #11849

merged 6 commits into from
Dec 17, 2024

Conversation

ericholscher
Copy link
Member

@ericholscher ericholscher commented Dec 11, 2024

This shows how to host docs with mdbook.

Requires #11848 to not need a reshim (example: https://github.com/readthedocs/test-builds/blob/mdbook/.readthedocs.yaml#L10)


📚 Documentation previews 📚

This shows how to host docs with mdbook.

Requires #11848 to not need a reshim
@ericholscher ericholscher changed the title mdbook example Add mdbook docs page Dec 11, 2024
Copy link
Member

@humitos humitos 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!

There are some things we should add to this guide:

  1. Integration with search to trigger ours when clicking on the search icon. Similar to what we wrote for MkDocs: https://docs.readthedocs.io/en/latest/intro/mkdocs.html#configure-read-the-docs-search
  2. Add custom CSS for flyout size
  3. Our search seems broken in the example. You cannot type the s letter for example.
  4. It would be good to add a small paragraph at least in the test-builds project 😄 . It only says "Chapter 1"

docs/user/intro/mdbook.rst Outdated Show resolved Hide resolved
docs/user/intro/mdbook.rst Outdated Show resolved Hide resolved
https://github.com/readthedocs/test-builds/tree/mdbook

Demo
https://test-builds.readthedocs.io/en/mdbook/
Copy link
Member

Choose a reason for hiding this comment

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

You should add custom CSS files to make the flyout looks nice; it's pretty small now:

Screenshot_2024-12-12_10-53-36

See an example for MkDocs: https://docs.readthedocs.io/en/latest/intro/mkdocs.html#adjust-the-flyout-menu-font-size

os: ubuntu-lts-latest
tools:
rust: latest
commands:
Copy link
Member

Choose a reason for hiding this comment

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

Have you tried using build.jobs.build.html instead? I think we should be recommending as much as possible that approach.

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't, but thought this was blocked on #11819

@ericholscher
Copy link
Member Author

ericholscher commented Dec 12, 2024

@humitos Should we be doing similar default configuration for the addons CSS selectors here, where we're able to detect the doctool and configure the Addons font size for example? It seems bad to punt this to the user if we know there's specific config we want for a tool, and we have the functionality to be able to detect the tool? 🤔

I feel like we're gonna get closer and closer to having magic on the front end if we keep adding in all these special cases tho, but I think it's unavoidable if we want to provide 💯 integrations for some of these tools.

@humitos
Copy link
Member

humitos commented Dec 16, 2024

Yes. I've been on the fence about adding those CSS rules automatically; but since they are --readthedocs-* specific CSS rules --so it's something we control and shouldn't have any impact in any other UI elements. Besides, I think we would want to add an option to opt-out from them "just in case" users are getting bad results (e.g. incorrect documentation tool detection, bad results, etc).

humitos added a commit to readthedocs/addons that referenced this pull request Dec 16, 2024
Use our heuristic to detect the documentation tool/theme and add specific
`--readthedocs-*` CSS variables based on that for known tools/themes.

Reference: readthedocs/readthedocs.org#11849 (comment)
.. code-block:: css
:caption: readthedocs.css:

:root {
Copy link
Member Author

Choose a reason for hiding this comment

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

@humitos This worked nicely in my test: https://test-builds.readthedocs.io/en/mdbook/

But it seems like the s key is hosed when search is open, because they're hooking into that to trigger their own search. 🙃

Copy link
Member

Choose a reason for hiding this comment

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

Looks great!

I remember having a similar issue with Material for MkDocs. They ended up fixing the issue on their side by skipping handling the keydown if the focus was inside a text input.

The options I see here are:

  • Disable their own search
  • Disable their hotkeys

I'm not sure if that's possible, tho.

@ericholscher
Copy link
Member Author

I'd like to get this merged so we can start ranking for it, and then futz with the final details of integration?

Copy link
Member

@humitos humitos 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, we can merge this.

There are some points we want to do after:

@humitos humitos merged commit e9316be into main Dec 17, 2024
8 checks passed
@humitos humitos deleted the mdbook-example branch December 17, 2024 11:01
@ericholscher
Copy link
Member Author

Looks like the code for this is here:

https://github.com/rust-lang/mdBook/blob/master/src/theme/searcher/searcher.js#L331-L335

Not really sure how to handle this -- I know we hit something similar with Mkdocs Material, but don't remember how we solved it.

@humitos
Copy link
Member

humitos commented Dec 17, 2024

I know we hit something similar with Mkdocs Material, but don't remember how we solved it.

They solved on their side. I commented this in the previous thread 😄 : #11849 (comment)

@ericholscher
Copy link
Member Author

I opened rust-lang/mdBook#2507

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