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

rst: runnableExamples affects rst underline headings #16990

Closed
timotheecour opened this issue Feb 9, 2021 · 2 comments
Closed

rst: runnableExamples affects rst underline headings #16990

timotheecour opened this issue Feb 9, 2021 · 2 comments
Labels
Documentation Generation Related to documentation generation (but not content).

Comments

@timotheecour
Copy link
Member

Example

## Basic Usage
## ===========
##
## some comment
##
## Lists1
## ------
##
## Lists2
## ------
##
runnableExamples:
  discard

## Lists3
## ------
##
runnableExamples:
  discard


## Lists4
## ------
runnableExamples:
  discard


## # Lists5
runnableExamples:
  discard


## ## Lists6
runnableExamples:
  discard

##[

# Lists7
## List 8
## List 9
foo
]##

Current Output

image

Expected Output

  • Lists4 ------ is a bug, should appear as List2
  • Lists3 is a bug, should appear as List2

everything else works fine

workaround

use markdown style prefix form (list5,...,list9) instead of underline form as was done in #16981
(not really a workaround since prefix form is IMO better style, more familiar for markdown users, and easier to use since you don't have to match the length of title with underline markers)

Additional Information

1.5.1 0d34345
/cc @a-mr since you've fixed many rst issues recently :)

@timotheecour timotheecour added the Documentation Generation Related to documentation generation (but not content). label Feb 9, 2021
@a-mr
Copy link
Contributor

a-mr commented Feb 10, 2021

there are 2 separate problems here:

  • (easy) when adornment is at the end of file/string then it's parsed as normal text Lists4-------
  • (hard) state is not shared between rstParse invocations for *.nim file. Essentially all RST fragments inside 1 nim file are parsed like separate documents! That's why RST parser determines first section in every doc comment as 1-level heading. I think it's always been present, other information is not shared b/w doc fragments also, e.g. this does not work as expected:
    ## Ref lnk_.
    discard
    ## .. _lnk: http://example.org/

I almost have a PR for the easy one.

Regarding the hard one - I think it would be logical to consider all doc comments as parts of one document, at least in sharing SharedState. @narimiran do you agree?

@timotheecour
Copy link
Member Author

Regarding the hard one - I think it would be logical to consider all doc comments as parts of one document, at least in sharing SharedState.

+1 to that. This may also help with nim-lang/RFCs#125 (DRY doc links) and the WIP RFC timotheecour#228 (lightweight refs in docs).

a-mr added a commit to a-mr/Nim that referenced this issue Jun 13, 2021
@Araq Araq closed this as completed in 590d457 Jun 20, 2021
PMunch pushed a commit to PMunch/Nim that referenced this issue Mar 28, 2022
* docgen: move to shared RST state (fix nim-lang#16990)

* Update lib/packages/docutils/rst.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>

* Update lib/packages/docutils/rst.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>

* Update lib/packages/docutils/rst.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>

* Update compiler/docgen.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Update compiler/docgen.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Update compiler/docgen.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* Update lib/packages/docutils/rst.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

* rename `cmdDoc2` to `cmdDoc`

* fix (P)RstSharedState convention

* new style of initialization

* misc suggestions

* 1 more rename

* fix a regression

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Generation Related to documentation generation (but not content).
Projects
None yet
Development

No branches or pull requests

2 participants