-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trim and dedent all Starlark doc strings following PEP-257
Documentation processors often require doc strings to be dedented. For example, Markdown interprets indented blocks as code. This means before handing doc strings to any form of API doc processor (and ideally - when storing the doc string), we want to dedent them to a minimal indentation level and trim blank lines. In the Python world, the standard algorithm for doing so is specified in PEP-257. Until now, we dedented multiline function doc strings in DocstringUtils using an algorithm which differed from PEP-257 in a number of corner cases. Meanwhile, all other docs (doc strings for rules, attributes, providers etc.) were not trimmed/dedented at all, despite often containing multiple lines. To fix, we introduce Starlark.trimDocString and use it comprehensively on all doc strings. Whenever possible, we store the docstring in its trimmed form. The one exception is function docstrings, because they are stored at parse time, not eval time; we have to trim them in the accessor method. This change allows us to massively simplify the DocstringUtils parser, since it no longer needs to mix low-level string munging for dedenting/trimming with the task of finding args, returns, and deprecation stanzas. A more comprehensive alternative to #13403 Fixes #13402 PiperOrigin-RevId: 552859517 Change-Id: I225f064c7b38f2fdbf78242d5b4597ec545518d4
- Loading branch information
1 parent
79163c9
commit b71b2df
Showing
20 changed files
with
357 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.