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

[JsonGen] Add pre/post conditions to docs #141

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions JsonGenerator/source/documentation_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,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
9 changes: 9 additions & 0 deletions JsonGenerator/source/header_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,15 @@ 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

if method.retval.meta.retval:
errors = []

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
Loading