mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
scripts/qapi/parser.py: improve doc comment indent handling
Make the handling of indentation in doc comments more sophisticated, so that when we see a section like: Notes: some text some more text indented line 3 we save it for the doc-comment processing code as: some text some more text indented line 3 and when we see a section with the heading on its own line: Notes: some text some more text indented text we also accept that and save it in the same form. If we detect that the comment document text is not indented as much as we expect it to be, we throw a parse error. (We don't complain about over-indented sections, because for rST this can be legitimate markup.) The golden reference for the doc comment text is updated to remove the two 'wrong' indents; these now form a test case that we correctly stripped leading whitespace from an indented multi-line argument definition. We update the documentation in docs/devel/qapi-code-gen.txt to describe the new indentation rules. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20200925162316.21205-6-peter.maydell@linaro.org> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Whitespace between sentences tweaked] Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
99dff36d3a
commit
a69a6d4b4d
7 changed files with 109 additions and 21 deletions
|
@ -901,6 +901,22 @@ commands and events), member (for structs and unions), branch (for
|
|||
alternates), or value (for enums), and finally optional tagged
|
||||
sections.
|
||||
|
||||
Descriptions of arguments can span multiple lines. The description
|
||||
text can start on the line following the '@argname:', in which case it
|
||||
must not be indented at all. It can also start on the same line as
|
||||
the '@argname:'. In this case if it spans multiple lines then second
|
||||
and subsequent lines must be indented to line up with the first
|
||||
character of the first line of the description:
|
||||
|
||||
# @argone:
|
||||
# This is a two line description
|
||||
# in the first style.
|
||||
#
|
||||
# @argtwo: This is a two line description
|
||||
# in the second style.
|
||||
|
||||
The number of spaces between the ':' and the text is not significant.
|
||||
|
||||
FIXME: the parser accepts these things in almost any order.
|
||||
FIXME: union branches should be described, too.
|
||||
|
||||
|
@ -911,6 +927,13 @@ A tagged section starts with one of the following words:
|
|||
"Note:"/"Notes:", "Since:", "Example"/"Examples", "Returns:", "TODO:".
|
||||
The section ends with the start of a new section.
|
||||
|
||||
The text of a section can start on a new line, in
|
||||
which case it must not be indented at all. It can also start
|
||||
on the same line as the 'Note:', 'Returns:', etc tag. In this
|
||||
case if it spans multiple lines then second and subsequent
|
||||
lines must be indented to match the first, in the same way as
|
||||
multiline argument descriptions.
|
||||
|
||||
A 'Since: x.y.z' tagged section lists the release that introduced the
|
||||
definition.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue