-
Notifications
You must be signed in to change notification settings - Fork 198
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
✨ NEW: Add toclist
extension
#485
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #485 +/- ##
==========================================
- Coverage 90.03% 89.74% -0.30%
==========================================
Files 16 16
Lines 2058 2097 +39
==========================================
+ Hits 1853 1882 +29
- Misses 205 215 +10
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Thanks for the prototype - my main question is: what is the problem that this addition is trying to solve? You mention this would let people write documentation purely with CommonMark - is that something people have been requesting? I think our main alternative would be to define a directive that behaved similarly, like:
You'd lose the "pure commonmark" aspect though. From a design standpoint:
I don't have super strong opinions in general - as long as this is an optional syntax I think it's fine to evolve it over time as people use it. |
Heya,
This is CommonMark syntax though. Perhaps you didn't realise the links can have titles? |
As explained in the initial comment, this would parse |
yes, particularly in the notebook context (also, as I note in the PR comment, it is similar to functionality recommonmark and nbsphinx already have)
Copied from Slack: To clarify, its not primarily meant to improve "user-friendliness" (although I believe it does), it is meant to improve "render-friendliness": if you use:
any non-myst renderer will just show literal text, whereas
will "correctly" show a link to the this is the "problem" being solved, not that users find it hard to use the toctree directive As an example, go to https://github.com/executablebooks/MyST-Parser/blob/32194f2d45f351419b9e4dc7975c9a9d0aba6946/docs/syntax/optional.md#table-of-contents-lists and if you click on the link, it will correctly take you to https://github.com/executablebooks/MyST-Parser/blob/32194f2d45f351419b9e4dc7975c9a9d0aba6946/docs/syntax/subsection.md.
this is why your suggestion does not solve the issue: you're still using it within a code fence, so it's still just going to be rendered as literal text |
Sorry a bit late to this party. I'm usually in favour of running these sort of extensions through a directive -- I typically think of core Not suggesting it would ever be, but I think it is important this type of extension would not be enabled by default (so it would be purely opt in syntax) |
just to clarify, no extensions are enabled by default, I will even be removing the current dollarmath on by default behaviour |
cheers for the feedback, its always welcome 👍 |
@chrisjsewell : I like the concept. How could we include :caption: in some way? Maybe
|
A few more thoughts below:
Ah gotcha - I did not realize that, you can disregard my comments about this not being CM compliant.
I agree that we can clarify things with documentation, though I worry this will still be unintuitive to folks so we'd pay a UX penalty even if it were documented. Since the main reason for using the
The syntax you proposed here seems reasonable to me:
|
@chrisjsewell: I just came across a use case for this extension again. Just one point: Some markdown linters complain if you use the same bullet element on different levels, so maybe do something like:
But it's also okay to keep everything "+" |
By adding
"toclist"
tomyst_enable_extensions
(in the sphinxconf.py
configuration file),you will be able to specify sphinx
toctree
in a Markdown native manner.toclist
are identified by bullet lists that use the+
character as the marker,and each item should be a link to another source file or an external hyperlink:
is equivalent to:
Note that the link text is omitted from the output
toctree
, and the title of the link is taken from either the link title, if present, or the title of the source file.You can also specify the
maxdepth
andnumbered
options for all toclist in yourconf.py
:Design notes:
toctree
is essentially the only directive/role strictly necessary to create multi-page sphinx sites.+
marker since I felt it is the least used of the possible CommonMark bullet markers (-
,*
,+
), so should generally not conflict with "standard" bullet lists[](page.md "title")
instead of[title](page.md)
. A key reason is because the latter is parsed to markdown tokens, and so you would need to convert it back to plain text, which would be tricky.toctree
options can only be set globally, usingmyst_toclist_maxdepth
,myst_toclist_numbered
. Specifying them pertoclist
would mean some kind of bespoke "decorator" syntax, which would complicate the implementation , and I feel is not necessary for most use cases.caption
would be nice to specify, see below...Some way to specify the
caption
, pertoclist
might be nice, preferably with minimal overhead on syntax/implementation code overhead.Possibly the simplest would be allowing an initial item with the caption:
Note, similar to entry titles, we would want to specify them as inline code, so they are not parsed as markdown.
A slightly more complex implementation would be to use nested lists, also allowing multiple toctrees in a single list:
would be equivalent to:
thoughts @choldgraf, @mmcky, etc?