Skip to content

Make ids of Markdown sub-documents prefixed with the parent item id#199

Merged
pawamoy merged 2 commits intomkdocstrings:masterfrom
oprypin:relid
Dec 22, 2020
Merged

Make ids of Markdown sub-documents prefixed with the parent item id#199
pawamoy merged 2 commits intomkdocstrings:masterfrom
oprypin:relid

Conversation

@oprypin
Copy link
Copy Markdown
Member

@oprypin oprypin commented Dec 22, 2020

@oprypin
Copy link
Copy Markdown
Member Author

oprypin commented Dec 22, 2020

Check out this test site with both tabs and footnotes with same ids working correctly:
https://gist.github.com/6d82074d3539851e6eaec6dc8db72dd2

This also fixes the issue I had mentioned where same headings in different docstrings would share the same id.

#a.foo, #examples, #b.foo, #examples becomes
#a.foo, #a.foo--examples, #b.foo, #b.foo--examples

@oprypin
Copy link
Copy Markdown
Member Author

oprypin commented Dec 22, 2020

@pawamoy
Copy link
Copy Markdown
Member

pawamoy commented Dec 22, 2020

Once again, fantastic contribution @oprypin 🚀 Thanks!
LGTM, lets see how it behaves in the regressions workflow 🙂

@pawamoy pawamoy merged commit d493d33 into mkdocstrings:master Dec 22, 2020
@oprypin
Copy link
Copy Markdown
Member Author

oprypin commented Jan 29, 2021

I notice that with this change, it is now possible link to stuff like [foo][some.identifier--subdoc-heading], and people are figuring it out. Should we embrace this or lock it down?

@pawamoy
Copy link
Copy Markdown
Member

pawamoy commented Feb 4, 2021

I think we should embrace it, this is a pretty nice feature. What's your opinion?

@oprypin
Copy link
Copy Markdown
Member Author

oprypin commented Feb 4, 2021

Overall I support it, I'm just disgruntled by the fact that I didn't realize this effect when I developed this PR, and also the choice of the "--" separator wasn't with this usage in mind, although maybe there isn't anything better.

@oprypin
Copy link
Copy Markdown
Member Author

oprypin commented Feb 4, 2021

For example, maybe people would've wanted to use some.identifier#subdoc-heading - but on the other hand, I'm already using the # symbol for identifiers in Crystal language, so it'd be ambiguous.

@pawamoy
Copy link
Copy Markdown
Member

pawamoy commented Feb 4, 2021

I like --. Headings IDs get slugified with - as separators, so a double -- makes sense to me to delimit the object identifier and the subheading. A bit like Django's ORM parameters using double underscores to avoid mistaking for another attribute: attribute__contains="some string". Or like escaping " with "" in CSV.

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

Labels

None yet

Projects

None yet

2 participants