-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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: flexible page structure #19328
Comments
Maybe be able to group by type (of the first parameter) for procs/macros/templates also? |
That sounds like a module divided into weakly-coupled sub-modules. It would be logical to split the module into a few files explicitly. And then use What about proposing another feature instead of p.2: In that case there is no need for adding special comments to every symbol. |
@a-mr having to split a source file to satisfy the needs of a documentation tool sounds quite heavy-handed and awkward. Also it would not satisfy the use-case 3. |
I can agree that we do need this feature without regard to that particular use case. Though adding a dedicated comment to each symbol still seems non-optimal. An example at the top of file: ## Chapter 1 name
## --------------
## .. symbols:: f1 f2 f3
##
## text text text...
##
## Chapter 2 name
## --------------
## .. symbols:: f4 f5 f6
...
proc f1*() = ...
const f2* = ... This directive can accept
The syntax will be normal RST, e.g. for case 3 this will work: ## .. symbols::
## :sort: on
## :headings: on
## f1 f2 f3 f4 f5 f6 So all symbols mentioned in any
This way there is no need in any flags for W.r.t. to Table of Contents (the left column) I suppose that it will always contain all sorted symbols. In case of What are you thoughts? |
The proposed mechanism is similar to It's worth reusing syntax, e.g. using this in a .. nim-doc:: lib/pure/os.nim
:identifiers: walkDir instead of This syntax is supposed to be used externally from We can do this inside .. nim-doc::
:identifiers: walkDir |
After pondering a little, I changed my opinion. It's worth to add an ordering without too much hustle. May be preferable solution is to get away with even simpler methods, without additional options: ## Module description
## Auxiliary code section
## -------------------------
proc a*() = ...
## Main code section
## --------------------
proc f*() = ...
proc g*() = ... Of course, we will probably want to change the order of sections — normally we have most important procs in the end of file because of Nim's requirement of usage after declaration. For that sake it's enough to introduce additional directive for reordering of sections, that could look like this: ## .. sections::
## :order:
## - Main code section
## - Auxiliary code section placed in Module description. I need to check feasibility of such approach esp. w.r.t. how forward declarations are represented in Nim AST. But anyway it seems the most simple and logical one. Generally speaking the problem is decomposed into 2 independent ones:
Here we will solve p.1. by making symbols follow RST/Markdown comment structure in 1st PR. Regarding p.2. — it can be implemented separately in 2nd PR, by addition of the following directive: ## .. symbols::
## :order: f g for precise order, ## .. symbols::
## :order-follows-code:
## :type-sections: off for the same order as code + turning off symbol kind headings ( |
Current state
nim doc
enforces a fixed order (Imports, Types, Consts, Procs, Templates) and sorts elements alphanumerically within each category.Yet, often procs/types/templates are grouped together in a source file based on what they do and the order is meaningful. Different groups are separated by comments.
Feature request
nim doc
could parse a flag in the source file and structure the generated HTML page in different ways:The text was updated successfully, but these errors were encountered: