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-9823 Apidocs: make sure that a derived "since" version value is not earlier... #2711

Merged
merged 1 commit into from
Aug 9, 2012
Merged
Changes from all 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
26 changes: 19 additions & 7 deletions apidoc/docgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def pretty_platform_name(name):
return "Mobile Web"

def combine_platforms_and_since(annotated_obj):
parent = annotated_obj.parent
obj = annotated_obj.api_obj
result = []
platforms = None
Expand All @@ -93,10 +94,10 @@ def combine_platforms_and_since(annotated_obj):
if (platforms is None or
isinstance(annotated_obj, AnnotatedMethod) or isinstance(annotated_obj, AnnotatedProperty) or
isinstance(annotated_obj, AnnotatedEvent)):
if annotated_obj.parent is not None:
if dict_has_non_empty_member(annotated_obj.parent.api_obj, "platforms"):
if platforms is None or len(annotated_obj.parent.api_obj["platforms"]) < len(platforms):
platforms = annotated_obj.parent.api_obj["platforms"]
if parent is not None:
if dict_has_non_empty_member(parent.api_obj, "platforms"):
if platforms is None or len(parent.api_obj["platforms"]) < len(platforms):
platforms = parent.api_obj["platforms"]
# Last resort is the default list of platforms
if platforms is None:
platforms = DEFAULT_PLATFORMS
Expand All @@ -106,9 +107,9 @@ def combine_platforms_and_since(annotated_obj):
# If a method/event/property we can check type's "since"
if (isinstance(annotated_obj, AnnotatedMethod) or isinstance(annotated_obj, AnnotatedProperty) or
isinstance(annotated_obj, AnnotatedEvent)):
if (annotated_obj.parent is not None and
dict_has_non_empty_member(annotated_obj.parent.api_obj, "since")):
since = annotated_obj.parent.api_obj["since"]
if (parent is not None and
dict_has_non_empty_member(parent.api_obj, "since")):
since = parent.api_obj["since"]

since_is_dict = isinstance(since, dict)
for name in platforms:
Expand All @@ -129,6 +130,17 @@ def combine_platforms_and_since(annotated_obj):
one_platform["since"] = DEFAULT_SINCE
result.append(one_platform)

# Be sure no "since" is _before_ a parent object since.
if parent and parent.platforms:
for entry in result:
platform_name = entry["name"]
version_parts = entry["since"].split(".")
for parent_entry in parent.platforms:
if parent_entry["name"] == platform_name:
parent_version_parts = parent_entry["since"].split(".")
if parent_version_parts > version_parts:
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't know you could do this in python. That is just insanely handy.

entry["since"] = parent_entry["since"]
break
return result

def load_one_yaml(filepath):
Expand Down