def generate_plugins(): """Generate overview table of default plugins.""" print("generating default plugins...") filename = "docs/documentation/configuration/default_plugins.rstsrc" plugins_directory = "vimiv/plugins" sys.path.insert(0, plugins_directory) plugin_names = sorted([ filename.replace(".py", "") for filename in os.listdir(plugins_directory) if not filename.startswith("_") and filename.endswith(".py") ]) def get_plugin_description(name): module = importlib.import_module(name, plugins_directory) docstring = inspect.getdoc(module) return docstring.split("\n")[0].strip(" .") rows = [("Name", "Description")] for name in plugin_names: rows.append((name, get_plugin_description(name))) with RSTFile(filename) as f: f.write_table(rows, title="Overview of default plugins", widths="20 80")
def generate_keybindings(): """Generate table overview of default keybindings.""" print("generating keybindings...") filename = "docs/documentation/configuration/keybindings_table.rstsrc" with RSTFile(filename) as f: for mode, bindings in api.keybindings.items(): rows = _gen_keybinding_rows(bindings) title = "Keybindings for %s mode" % (mode.name) f.write_table(rows, title=title, widths="20 80")
def generate_settings(): """Generate table overview of all settings.""" print("generating settings...") filename = "docs/documentation/configuration/settings_table.rstsrc" with RSTFile(filename) as f: rows = [("Setting", "Description")] for name in sorted(api.settings._storage.keys()): setting = api.settings._storage[name] if setting.desc: # Otherwise the setting is meant to be hidden rows.append((name, setting.desc)) f.write_table(rows, title="Overview of settings", widths="30 70")
def generate_status_modules(): """Generate table overview of status modules.""" print("generating statusbar modules...") filename = "docs/documentation/configuration/status_modules.rstsrc" with RSTFile(filename) as f: rows = [("Module", "Description")] for name in sorted(api.status._modules.keys()): func = api.status._modules[name]._func name = name.strip("{}") desc = inspect.getdoc(func).split("\n")[0] rows.append((name, desc)) f.write_table(rows, title="Overview of status modules", widths="30 70")
def generate_commands(): """Generate table overview and description of the commands.""" print("generating commands...") with RSTFile("docs/documentation/commands_desc.rstsrc") as f: for mode, cmds in api.commands._registry.items(): f.write_subsection(mode.name.capitalize()) # Table of command overview rows = [("Command", "Description")] title = "Overview of %s commands" % (mode.name) for name in sorted(cmds.keys()): cmd = cmds[name] link = ":ref:`ref_%s_%s`" % (mode.name, name) rows.append((link, cmd.description)) f.write_table(rows, title=title, widths="25 75") _write_command_description(cmds, mode.name, f)
def generate_commandline_options(): """Generate file including the command line options.""" argparser = parser.get_argparser() groups, titles = _get_options(argparser) # Synopsis filename_synopsis = "docs/manpage/synopsis.rstsrc" with open(filename_synopsis, "w") as f: synopsis_options = ["[%s]" % (title) for title in titles] synopsis = "**vimiv** %s" % (" ".join(synopsis_options)) f.write(synopsis) # Options filename_options = "docs/manpage/options.rstsrc" with RSTFile(filename_options) as f: for title, argstr in groups.items(): f.write_section(title) f.write(argstr)
def generate_commandline_options(): """Generate file including the command line options.""" parser = startup.get_argparser() optionals, positionals, titles = _get_options(parser) # Synopsis filename_synopsis = "docs/manpage/synopsis.rstsrc" with open(filename_synopsis, "w") as f: synopsis_options = ["[%s]" % (title) for title in titles] synopsis = "**vimiv** %s" % (" ".join(synopsis_options)) f.write(synopsis) # Options filename_options = "docs/manpage/options.rstsrc" with RSTFile(filename_options) as f: f.write_section("positional arguments") f.write(positionals) f.write_section("optional arguments") f.write(optionals)