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

Timob 9799: Apidoc: New "repeatable" key for method parameter documentation (vararg) #2719

Merged
merged 3 commits into from
Aug 14, 2012
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions apidoc/docgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,10 @@ def __init__(self, api_obj, annotated_parent):
self.parent = annotated_parent
self.typestr = "parameter"
self.yaml_source_folder = self.parent.yaml_source_folder
if "repeatable" in api_obj:
self.repeatable = api_obj["repeatable"]
else:
self.repeatable = None

class AnnotatedProperty(AnnotatedApi):
def __init__(self, api_obj, annotated_parent):
Expand Down
13 changes: 11 additions & 2 deletions apidoc/templates/html/member_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
%>
<% platform_names = ", ".join([p["pretty_name"] for p in item.platforms]) %>
<% append_cell_class = " deprecated" if item.deprecated else "" %>
<%
if hasattr(item, "repeatable") and item.repeatable:
item_name = "%s..." % item.name
else:
item_name = item.name
%>
<%
summary = item.summary_html
was_para_close = False
Expand All @@ -28,9 +34,9 @@

<tr class="${row_class}">
% if item.typestr=="parameter" or (item.typestr=="property" and item.parent.typestr=="event"):
<td class="name${append_cell_class}">${item.name}</td>
<td class="name${append_cell_class}">${item_name}</td>
% else:
<td class="name${append_cell_class}"><a href="${item.filename_html}.html">${item.name}</a></td>
<td class="name${append_cell_class}"><a href="${item.filename_html}.html">${item_name}</a></td>
% endif
% if is_property_list:
<td class="type${append_cell_class}">${item.type_html}</td>
Expand All @@ -56,6 +62,9 @@
% if item.optional is not None:
<span class="optional">Optional.</span>
% endif
% if item.repeatable:
<span class="optional">Repeatable.</span>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think we really needed a new class for "repeatable", since whatever the styling on "optional" is/was, I imagine it's just fine for "repeatable". And I guess with jsduck in use now, it doesn't really matter??

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm with you.

% endif
% if item.default is not None:
<%
if item.default_html.startswith("<p>"):
Expand Down
5 changes: 4 additions & 1 deletion apidoc/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"events"],
"method": ["name", "summary", "description", "returns", "platforms", "since",
"deprecated", "osver", "examples", "parameters"],
"parameter": ["name", "summary", "type", "optional", "default"],
"parameter": ["name", "summary", "type", "optional", "default", "repeatable"],
"property": ["name", "summary", "description", "type", "platforms", "since",
"deprecated", "osver", "examples", "permission", "availability", "accessors",
"optional", "value", "default"],
Expand Down Expand Up @@ -315,6 +315,9 @@ def validateCommon(tracker, map):
if 'optional' in map:
validateIsBool(tracker, 'optional', map['optional'])

if 'repeatable' in map:
validateIsBool(tracker, 'repeatable', map['repeatable'])

if 'notes' in map:
tracker.trackError('"notes" field is no longer valid')

Expand Down