Skip to content

Better sidebar/navbar rendering from the Documenter end #278

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

asinghvi17
Copy link
Collaborator

@asinghvi17 asinghvi17 commented Jun 5, 2025

This allows an extensible interface (and significantly cleans up the interface in general). (doc::Documenter.Document).user.pages is strictly typed to be a Vector{Any} so we can't dispatch intelligently on that, but you can carve out a single dispatch on Vector{<: Any} that will let you interrogate the structure of an array. Can only do that once per Julia session.

This lets us do in Julia what the Lux docs do manually. Specifically, note how the sidebar changes here.

Screen.Recording.2025-06-05.at.8.09.48.AM.mov

Copy link

codecov bot commented Jun 5, 2025

Codecov Report

Attention: Patch coverage is 0% with 74 lines in your changes missing coverage. Please review.

Project coverage is 7.42%. Comparing base (fed5b13) to head (15b538f).

Files with missing lines Patch % Lines
src/vitepress_config.jl 0.00% 37 Missing ⚠️
src/writer.jl 0.00% 21 Missing ⚠️
src/frontmatter.jl 0.00% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           master    #278      +/-   ##
=========================================
- Coverage    7.73%   7.42%   -0.31%     
=========================================
  Files           6       7       +1     
  Lines         892     929      +37     
=========================================
  Hits           69      69              
- Misses        823     860      +37     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

],
"Developers' documentation" => [
]),
DecomposeInSidebar("devs", "Developers' documentation" => [
Copy link
Collaborator

Choose a reason for hiding this comment

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

it's a nice thing to have, but I don't love the name. I don't feel that it communicates his purpose fully.

Copy link
Collaborator Author

@asinghvi17 asinghvi17 Jun 6, 2025

Choose a reason for hiding this comment

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

Yeah it's more a test at this point. We can move this in and refactoring before merge.

Copy link
Collaborator

@lazarusA lazarusA left a comment

Choose a reason for hiding this comment

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

Maybe, we could make it the default? so to further typing is not needed. We will need to do a breaking release though. We could add also #266 to it.

Edit: and if it's the default, then use SplitNot, doNoSplit, splitFalse or something to avoid it.

@asinghvi17
Copy link
Collaborator Author

It's too prescriptive to be the default imo

@jkrumbiegel
Copy link
Collaborator

I don't think I get this, why can you only do something once per julia session that involves a normal method on a function you own?

@asinghvi17
Copy link
Collaborator Author

I should probably revise that. I meant to say only one such override can ever be active at a time. You can override that method but the old one is then inaccessible.

return invoke(pagelist2str, Tuple{Any, Any, Val{:sidebar}}, doc, ds, Val(:sidebar))
end
contents = DocumenterVitepress.pagelist2str.((doc,), ds, (Val(:sidebar),))
ret = "{\n" * join(contents, ",\n") * "\n}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest just taking a dep on some JSON package rather than having this brittle manual construction code, it's easy to mess up escaping etc.


# So you can only really pull this trick once in a Julia session
# But because doc.user.pages is a Vector{Any}, we can't really do anything about it.
function DocumenterVitepress.pagelist2str(doc, ds::Vector{<: Any}, ::Val{:sidebar})
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you explain what this is supposed to do and why you need the invoke? I'm not sure yet if this DecomposeInSidebar thing shouldn't work differently, but I'm also not quite getting yet how you intended it

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