diff options
author | Michael DeHaan <michael@ansibleworks.com> | 2013-12-25 13:23:58 -0500 |
---|---|---|
committer | Michael DeHaan <michael@ansibleworks.com> | 2013-12-25 13:24:29 -0500 |
commit | 35ec9f81ae567dadc0947d962b95a0f61904a938 (patch) | |
tree | e7cc4d80bcead62892d76296cdeb731f2e6c2382 /hacking | |
parent | fe2d00d9d338e43071f7382fa7d414cb30706839 (diff) | |
download | ansible-35ec9f81ae567dadc0947d962b95a0f61904a938.tar.gz |
Further modifications to the module formatter to adjust to the new theme, and some misc docs text corrections.
Diffstat (limited to 'hacking')
-rwxr-xr-x | hacking/module_formatter.py | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/hacking/module_formatter.py b/hacking/module_formatter.py index f6ab8d596a..787bf4e2d2 100755 --- a/hacking/module_formatter.py +++ b/hacking/module_formatter.py @@ -102,7 +102,7 @@ def rst_xline(width, char="="): ##################################################################################### -def return_data(text, options, outputname, module): +def write_data(text, options, outputname, module): ''' dumps module output to a file or the screen, as requested ''' if options.output_dir is not None: @@ -188,7 +188,7 @@ def jinja2_environment(template_dir, typ): env.filters['fmt'] = rst_fmt env.filters['xline'] = rst_xline template = env.get_template('rst.j2') - outputname = "%s.rst" + outputname = "%s_module.rst" else: raise Exception("unknown module format type: %s" % typ) @@ -214,7 +214,7 @@ def process_module(module, options, env, template, outputname, module_map): sys.stderr.write("*** ERROR: CORE MODULE MISSING DOCUMENTATION: %s, %s ***\n" % (fname, module)) sys.exit(1) if doc is None: - return + return "SKIPPED" all_keys = [] @@ -250,7 +250,7 @@ def process_module(module, options, env, template, outputname, module_map): # here is where we build the table of contents... text = template.render(doc) - return_data(text, options, outputname, module) + write_data(text, options, outputname, module) ##################################################################################### @@ -258,6 +258,10 @@ def process_category(category, categories, options, env, template, outputname): module_map = categories[category] + category_file_path = os.path.join(options.output_dir, "list_of_%s_modules.rst" % category) + category_file = open(category_file_path, "w") + print "*** recording category %s in %s ***" % (category, category_file_path) + # TODO: start a new category file category = category.replace("_"," ") @@ -266,8 +270,22 @@ def process_category(category, categories, options, env, template, outputname): modules = module_map.keys() modules.sort() + category_header = "%s Modules" % (category.title()) + underscores = "`" * len(category_header) + + category_file.write(category_header) + category_file.write("\n") + category_file.write(underscores) + category_file.write("\n") + category_file.write(".. toctree::\n") + for module in modules: - process_module(module, options, env, template, outputname, module_map) + result = process_module(module, options, env, template, outputname, module_map) + if result != "SKIPPED": + category_file.write(" %s_module\n" % module) + + + category_file.close() # TODO: end a new category file @@ -305,9 +323,19 @@ def main(): last_category = None category_names = categories.keys() category_names.sort() + + category_list_path = os.path.join(options.output_dir, "modules_by_category.rst") + category_list_file = open(category_list_path, "w") + category_list_file.write("Module Index\n") + category_list_file.write("============\n") + category_list_file.write("\n\n") + category_list_file.write(".. toctree::\n") for category in category_names: + category_list_file.write(" list_of_%s_modules\n" % category) process_category(category, categories, options, env, template, outputname) + category_list_file.close() + if __name__ == '__main__': main() |