Skip to content

Commit

Permalink
[JsonGen] Add pre/post conditions to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sebaszm committed Dec 16, 2024
1 parent b7224e1 commit 81e2a51
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions JsonGenerator/source/documentation_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ def MethodDump(method, props, classname, section, header, is_notification=False,

MdParagraph(text)

if "preconditions" in props:
MdParagraph("Preconditions: %s" % props["preconditions"])
if "postconditions" in props:
MdParagraph("Postconditions: %s" % props["postconditions"])

if is_property:
if "readonly" in props and props["readonly"]:
MdParagraph("> This property is **read-only**.")
Expand Down
6 changes: 6 additions & 0 deletions JsonGenerator/source/header_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,12 @@ def BuildResult(vars, is_property=False, test=False):
if method.retval.meta.details:
obj["description"] = method.retval.meta.details.strip()

if method.retval.meta.pre:
obj["preconditions"] = method.retval.meta.pre.strip()

if method.retval.meta.post:
obj["postconditions"] = method.retval.meta.post.strip()

if lookup_method:
obj["@lookup"] = lookup_method

Expand Down
13 changes: 12 additions & 1 deletion ProxyStubGenerator/CppParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ def __init__(self):
self.sourcelocation = ""
self.brief = ""
self.details = ""
self.pre = ""
self.post = ""
self.input = False
self.output = False
self.length = None
Expand Down Expand Up @@ -427,6 +429,12 @@ def __init__(self, parent_block, parent, string, valid_specifiers, tags_allowed=
elif tag == "DETAILS":
self.meta.details = string[i + 1]
skip = 1
elif tag == "PRE":
self.meta.pre = string[i + 1]
skip = 1
elif tag == "POST":
self.meta.post = string[i + 1]
skip = 1
elif tag == "PARAM":
par = string[i + 1]
if par.endswith(":"):
Expand Down Expand Up @@ -1825,6 +1833,8 @@ def EndOfTag(string, start):

FindDoxyString("@brief", False, token, tagtokens)
FindDoxyString("@details", False, token, tagtokens)
FindDoxyString("@pre", False, token, tagtokens)
FindDoxyString("@post", False, token, tagtokens)
FindDoxyString("@param", True, token, tagtokens)
FindDoxyString("@retval", True, token, tagtokens)

Expand Down Expand Up @@ -1982,7 +1992,6 @@ def Parse(contents,log = None):
i += 1
elif tokens[i] == "@EVENT":
event_next = True
json_next = False
tokens[i] = ";"
i += 1
elif tokens[i] == "@TEXT":
Expand Down Expand Up @@ -2153,6 +2162,8 @@ def Parse(contents,log = None):
if json_next:
new_class.is_json = True
new_class.json_version = json_version
if event_next:
raise ParserError("@json iterface cannot also be @event")
if prefix_next:
new_class.json_prefix = prefix_string
if event_next:
Expand Down

0 comments on commit 81e2a51

Please sign in to comment.