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

[docgen] runnableExamples causes subsection to be rendered as a section #15176

Closed
nitely opened this issue Aug 11, 2020 · 3 comments · Fixed by #23248
Closed

[docgen] runnableExamples causes subsection to be rendered as a section #15176

nitely opened this issue Aug 11, 2020 · 3 comments · Fixed by #23248
Labels
Documentation Generation Related to documentation generation (but not content). works_but_needs_test_case

Comments

@nitely
Copy link
Contributor

nitely commented Aug 11, 2020

Maybe this is intended, or the right way is to use .. code-block:: nim with :test:. If that's the case close this.

Example

##[
Section
*********

Subsection 1
###########

]##
runnableExamples:
  doAssert true
##[
Subsection 2
###########

]##

Current Output

"Subsection 2" is rendered as <h1>Subsection 2</h1>

Expected Output

"Subsection 2" is rendered as <h2>Subsection 2</h2>

Additional Information

Using a code block works as expected:

.. code-block:: nim
    :test:
    doAssert true
$ nim -v
Nim Compiler Version 1.3.5 [Linux: amd64]
Compiled at 2020-08-03
Copyright (c) 2006-2020 by Andreas Rumpf
@ringabout ringabout added the Documentation Generation Related to documentation generation (but not content). label Nov 10, 2020
@timotheecour
Copy link
Member

timotheecour commented Dec 2, 2020

reduced:
the root cause isn't runnableExamples, it's the fact that headings are wrong when doc comment is split in multiple parts:

case3 bugs, case3b works

when defined case3:
  ## Basic usage
  ## ===========
  ##
  ## Encoding data
  ## -------------
  ##
  ## Apart from strings you can also encode lists of integers or characters:

  ## Decoding data
  ## -------------
  ##

when defined case3b:
  ## Basic usage
  ## ===========
  ##
  ## Encoding data
  ## -------------
  ##
  ## Apart from strings you can also encode lists of integers or characters:
  ##
  ## Decoding data
  ## -------------
  ##

@timotheecour
Copy link
Member

@a-mr it turns out your PR #18256 also fixes this issue; do we need a test case for this before closing? (ideally using toAst)

it's not clear to me whether #18256 actually did add a test for this (at least not ones based on toAst, only html)

@a-mr
Copy link
Contributor

a-mr commented Jun 20, 2021

@timotheecour ,
no tests were added in #18256 , so i need to add tests in a follow-up PR.

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). works_but_needs_test_case
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants