diff options
author | Patrick Totzke <patricktotzke@gmail.com> | 2012-02-21 21:26:51 +0000 |
---|---|---|
committer | Patrick Totzke <patricktotzke@gmail.com> | 2012-02-21 21:30:39 +0000 |
commit | df97ee9c181dff81da66b65e0a9e789b5c901a44 (patch) | |
tree | b4161d67e1aedf5e532037fe5e73beaf57c4f223 /docs | |
parent | 64d76dac8b1aa6cdcdd5e54b8e6db9df8eef93ac (diff) |
auto-generate config docs from specfiles
Diffstat (limited to 'docs')
-rw-r--r-- | docs/Makefile | 5 | ||||
-rwxr-xr-x | docs/source/generate_configs.py | 29 |
2 files changed, 32 insertions, 2 deletions
diff --git a/docs/Makefile b/docs/Makefile index 29be0741..7668b4da 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -33,8 +33,9 @@ help: @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" -generate_commands: - python source/generate_commands.py > source/usage/commands.rst +generate_meta: + python source/generate_commands.py + python source/generate_configs.py clean: -rm -rf $(BUILDDIR)/* diff --git a/docs/source/generate_configs.py b/docs/source/generate_configs.py new file mode 100755 index 00000000..90cf0cf9 --- /dev/null +++ b/docs/source/generate_configs.py @@ -0,0 +1,29 @@ +import sys +import os +HERE = os.path.dirname(__file__) +sys.path.append(os.path.join(HERE, '..', '..', '..')) +from alot.commands import COMMANDS +from configobj import ConfigObj +import re + +def rewrite_scalarcomments(config, path): + file = open(path, 'w') + for entry in config.scalars: + description = '\n.. describe:: %s\n\n' % entry + comments = [config.inline_comments[entry]] + config.comments[entry] + for c in comments: + if c: + description += ' '*4 + re.sub('^\s*#\s*', '', c) + '\n' + file.write(description) + file.close() + +if __name__ == "__main__": + specpath = os.path.join(HERE, '..','..', 'alot', 'defaults', 'alot.rc.spec') + config = ConfigObj(specpath) + + alotrc_table_file = os.path.join(HERE, 'configuration', 'alotrc_table.rst') + rewrite_scalarcomments(config, alotrc_table_file) + + rewrite_scalarcomments(config['accounts']['__many__'], + os.path.join(HERE, 'configuration', + 'accounts_table.rst')) |