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

macro documentation has extra indent #74

Closed
alexeagle opened this issue Oct 15, 2020 · 0 comments
Closed

macro documentation has extra indent #74

alexeagle opened this issue Oct 15, 2020 · 0 comments

Comments

@alexeagle
Copy link
Contributor

python docstrings have to indent paragraphs under a parameter, for example for TypeScript we have this Args: section

https://github.com/bazelbuild/rules_nodejs/blob/ad0e2a4db40f0214ca6fc670d165c15c18de64ee/packages/typescript/internal/ts_project.bzl#L374-L419

The indent underneath each attribute is required to make the docstring syntax comply with the standard and for tools to parse it. In particular we have that line EXPERIMENTAL: generated tsconfig which is not documenting a parameter, it's just some more text in the documentation for tsconfig

When Stardoc produces the protobuf of the docstring the extra indent is still in there.

Note that it works out okay when you render the result in a place that isn't whitespace-sensitive, like in an HTML table. However if you render it in markdown you get a codeblock for each paragraph since leading indent is a markdown syntax for code block.

I think stardoc should de-dent this to canonicalize the doc back to what the author intended, by removing the four spaces from each line after the first in the docstring. so for my tsconfig attribute the proto's docString should be

Label of the tsconfig.json file to use for the compilation
To support "chaining" of more than one extended config, this label could be a target that
provdes <code>TsConfigInfo</code> such as <code>ts_config</code>.

By default, we assume the tsconfig file is named by adding <code>.json</code> to the <code>name</code> attribute.

EXPERIMENTAL: generated tsconfig

Instead of a label, you can pass a dictionary of tsconfig keys.

In this case, a tsconfig.json file will be generated for this compilation, in the following way:
- all top-level keys will be copied by converting the dict to json.
    So <code>tsconfig = {"compilerOptions": {"declaration": True}}</code>
    will result in a generated <code>tsconfig.json</code> with <code>{"compilerOptions": {"declaration": true}}</code>
- each file in srcs will be converted to a relative path in the <code>files</code> section.
- the <code>extends</code> attribute will be converted to a relative path

Note that you can mix and match attributes and compilerOptions properties, so these are equivalent:
...
alexeagle pushed a commit to alexeagle/bazel that referenced this issue Oct 15, 2020
This allows multi-line parameter documentation under Args: without extra indents.
Fixes bazelbuild/stardoc#74
alexeagle pushed a commit to alexeagle/bazel that referenced this issue Oct 15, 2020
This allows multi-line parameter documentation under Args: without extra indents.
Fixes bazelbuild/stardoc#74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant