From 2a2eafa2823d9215ca2b2a7dbbe273879d0e0590 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Wed, 23 May 2018 14:31:15 +0100 Subject: [PATCH] utils/doc: include plugin aliases in the docs If a plugin defines aliases, include the aliases and the parameter values they correspond to inside the docs. --- wa/utils/doc.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/wa/utils/doc.py b/wa/utils/doc.py index 2ae339a0..56fb39ff 100644 --- a/wa/utils/doc.py +++ b/wa/utils/doc.py @@ -294,6 +294,15 @@ def get_params_rst(parameters): return text +def get_aliases_rst(aliases): + text = '' + for alias in aliases: + param_str = ', '.join(['{}={}'.format(n, format_literal(v)) + for n, v in alias.params.iteritems()]) + text += '{}\n{}\n'.format(alias.name, indent(param_str)) + return text + + def underline(text, symbol='='): return '{}\n{}\n\n'.format(text, symbol * len(text)) @@ -312,7 +321,13 @@ def get_rst_from_plugin(plugin): else: desc = '' text += desc + '\n\n' + + aliases_rst = get_aliases_rst(plugin.aliases) + if aliases_rst: + text += underline('aliases', '~') + aliases_rst + params_rst = get_params_rst(plugin.parameters) if params_rst: text += underline('parameters', '~') + params_rst + return text + '\n'