Skip to content

Commit

Permalink
Merge pull request #4210 from jonalter/timob-10688
Browse files Browse the repository at this point in the history
[TIMOB-10688]
  • Loading branch information
bhatfield committed Jun 26, 2013
2 parents 33c649d + 71676c4 commit 911d9ae
Show file tree
Hide file tree
Showing 25 changed files with 1,122 additions and 5 deletions.
24 changes: 21 additions & 3 deletions apidoc/docgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
ignore_dirs = (".git", ".svn", "CVS")
ignore_files = ("template.yml",)
warn_inherited = False # see optparse option with same name in main()
options = None

def has_ancestor(one_type, ancestor_name):
if one_type["name"] == ancestor_name:
Expand Down Expand Up @@ -162,9 +163,15 @@ def generate_output(options):
generator = getattr(generators, "%s_generator" % output_type)
generator.generate(apis, annotated_apis, options)

def process_yaml(source_dirs):
def process_yaml(source_dirs, options=None):
global apis
log.info("Parsing YAML files")

if options and options.exclude_external and len(source_dirs) <= 1:
log.error("At least one path must be passed when using -e or --exclude-external")
sys.exit(1)
tag_external = True if options and options.exclude_external else False

for source_dir in source_dirs:
for root, dirs, files in os.walk(source_dir):
for name in ignore_dirs:
Expand All @@ -183,7 +190,9 @@ def process_yaml(source_dirs):
for one_type in types:
if one_type["name"] in apis:
log.warn("%s has a duplicate" % one_type["name"])
one_type["external"] = tag_external
apis[one_type["name"]] = one_type
tag_external = False

# If documentation for a method/event/property only "partially overrides"
# the documentation for the super type, this will fill in the rest of
Expand Down Expand Up @@ -292,6 +301,10 @@ def __init__(self, api_obj):
self.optional = api_obj["optional"]
else:
self.optional = None
if "external" in api_obj:
self.external = api_obj["external"]
else:
self.external = False

@lazyproperty
def platforms(self):
Expand Down Expand Up @@ -574,7 +587,7 @@ def properties(self):
return sorted(properties, key=lambda item: item.name)

def main():
global this_dir, log, warn_inherited
global this_dir, log, warn_inherited, options
titanium_dir = os.path.dirname(this_dir)
dist_apidoc_dir = os.path.join(titanium_dir, "dist", "apidoc")
sys.path.append(os.path.join(titanium_dir, "build"))
Expand Down Expand Up @@ -617,6 +630,11 @@ def main():
action="store_true",
help="Show a warning if the documentation for a method/property/event only partially overrides its super type's documentation, in which case the missing information is inherited from the super type documentation.",
default=False)
parser.add_option("-e", "--exclude-external",
dest="exclude_external",
action="store_true",
help="Will not generate output from the titanium doc foler, must pass a path to a documentation folder",
default=False)
(options, args) = parser.parse_args()
warn_inherited = options.warn_inherited
log_level = TiLogger.INFO
Expand All @@ -629,7 +647,7 @@ def main():

load_generators(options)
source_dirs = [ this_dir ] + args
process_yaml(source_dirs)
process_yaml(source_dirs, options)
finish_partial_overrides()
generate_output(options)

Expand Down
3 changes: 3 additions & 0 deletions apidoc/generators/jsca_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ def to_jsca_since(platforms):
}, ("name",)) for platform in platforms]

def to_jsca_type(api):
# Objects marked as external should be ignored
if api.external:
return None
if api.name in not_real_titanium_types:
return None
log.trace("Converting %s to jsca" % api.name)
Expand Down

0 comments on commit 911d9ae

Please sign in to comment.