From 0740316bd2f35d297f02b08e219765272ecc6822 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Mon, 9 Jul 2012 17:02:12 +0200 Subject: [PATCH] Migrate doc/make_target_table.py to Catalyst 2.x and Python 2.x --- Makefile | 2 +- doc/make_target_table.py | 29 +++++++++++++++++++++-------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index bbdb525d..ba802ad2 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ $(MAN_PAGES): files/%: doc/%.txt $(MAN_PAGE_INCLUDES) doc/asciidoc.conf Makefile doc/subarches.generated.txt: $(wildcard arch/*.py) doc/make_subarch_table_guidexml.py ./doc/make_subarch_table_guidexml.py -doc/targets.generated.txt: doc/make_target_table.py $(wildcard modules/catalyst/targets/*.py) +doc/targets.generated.txt: doc/make_target_table.py $(wildcard modules/*_target.py) "./$<" > "$@" clean: diff --git a/doc/make_target_table.py b/doc/make_target_table.py index 1bacbe28..b72935fa 100755 --- a/doc/make_target_table.py +++ b/doc/make_target_table.py @@ -1,21 +1,34 @@ #!/usr/bin/env python # Copyright (C) 2012 W. Trevor King +# Copyright (C) 2012 Sebastian Pipping # Licensed under GPL v2 or later # This script should be run from the root of the catalyst source. +from __future__ import print_function + import sys as _sys _sys.path.insert(0, 'modules') # so we can find the `catalyst` module -import catalyst.target as _catalyst_target +import glob +import re if __name__ == '__main__': - for module_name,module in sorted(_catalyst_target.get_targets().items()): - if hasattr(module, '__target_map'): - target_name = module.__target_map.keys()[0] - print('`{}`;;'.format(target_name)) - # Replace blank lines with `+` (asciidoc list item continuation) - print(module.__doc__.strip().replace('\n\n', '\n+\n')) - print('') + extractor = re.compile('^modules/(([^ ]+)_target).py$') + for filename in sorted(glob.glob('modules/*_target.py')): + if 'generic' in filename: + continue + + match = extractor.match(filename) + target_name = match.group(2).replace('_', '-') + module_name = match.group(1) + + __import__(module_name) + module = _sys.modules[module_name] + + print('`%s`;;' % target_name) + # Replace blank lines with `+` (asciidoc list item continuation) + print(module.__doc__.strip().replace('\n\n', '\n+\n')) + print('') -- 2.26.2