Skip to content

Adds a AnchorLink.level property - #1272

Closed
funkyfuture wants to merge 1 commit into
mkdocs:1.0.devfrom
funkyfuture:toc_depth
Closed

funkyfuture wants to merge 1 commit into
mkdocs:1.0.devfrom
funkyfuture:toc_depth

Conversation

@funkyfuture

@funkyfuture funkyfuture commented Sep 6, 2017 •

Copy link
Copy Markdown
Contributor

this allows themes to restrict the toc to a certain depth.

here's a proof-of-concept: squidfunk/mkdocs-material#450

@waylan

waylan commented Sep 6, 2017

Copy link
Copy Markdown
Contributor

Hmm, so this adds a level attribute to the AnchorLink class to track the "level" of each item in a template. Is that really necessary? Why can't you track that with a template variable? In other words, convince me this is the right approach to the problem.

Regardless, this would need to have some tests. Also, it should be against the 1.0.dev branch. Finally, as this would be a 1.0 feature, the template specific setting (in the associated Material PR) may want to take advantage of the new template settings implemented in #1201,

@funkyfuture

Copy link
Copy Markdown
Contributor Author

Is that really necessary? Why can't you track that with a template variable? In other words, convince me this is the right approach to the problem.

in general i tend to keep the logic in templates at a minimum and rather pass rich context objects. imo this is easier to read in the templates. also, all theme developers and users can easily access this information w/o implementing a logic for it. it's obviously simply implemented and maintainable on the Python side.

thanks for the other hints.

@funkyfuture
funkyfuture changed the base branch from master to 1.0.dev September 7, 2017 11:51
@waylan waylan added this to the 1.0.0 milestone Sep 7, 2017
@waylan

waylan commented Sep 7, 2017

Copy link
Copy Markdown
Contributor

Add some tests and I'll give this another look.

@funkyfuture

Copy link
Copy Markdown
Contributor Author

a test is added. the fails are caused by missing interpreters.

This allows themes to restrict the toc to a certain depth.
waylan added a commit to waylan/mkdocs that referenced this pull request Jun 29, 2018
This relimplements mkdocs#1272 on the current code in master. Thanks to 
@funkyfuture for the original work on this.

Also removes some unused code after mkdocs#1504.

Closes mkdocs#1272.
@waylan waylan closed this in #1520 Jun 29, 2018
waylan added a commit that referenced this pull request Jun 29, 2018
This relimplements #1272 on the current code in master. Thanks to 
@funkyfuture for the original work on this.

Also removes some unused code after #1504.

Closes #1272.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants