Browse Source

Support files as source for dn2osdbk

The current version only uses directory as source for tranformation.
This patch allows to work on a single source file. This is intended to
be used to generated the HOT reference data.

Change-Id: I574c099c26718e0ca509a492e857c96e7bdc0e15
changes/83/111583/1
Gauvain Pocentek 7 years ago
parent
commit
0180dbe580
  1. 1
      RELEASE_NOTES.rst
  2. 17
      os_doc_tools/dn2osdbk.py

1
RELEASE_NOTES.rst

@ -5,6 +5,7 @@ Release notes
----
* ``openstack-doc-test``: Don't always build the HOT guide
* ``openstack-dn2osdbk``: Allow single files as source
0.17
----

17
os_doc_tools/dn2osdbk.py

@ -209,16 +209,23 @@ class ChapterTransformer(BaseFolderTransformer):
def main():
parser = argparse.ArgumentParser(description="Generate docbook from "
"DocUtils Native XML format")
parser.add_argument('source', help='Source directory.')
parser.add_argument('output', help='Output file.')
parser.add_argument('source', help='Source file or directory.')
parser.add_argument('output', help='Output file or directory.')
parser.add_argument('--toplevel', help='Toplevel flag.',
choices=['book', 'chapter'],
default='chapter')
args = parser.parse_args()
cls = globals()[TRANSFORMERS[args.toplevel]]
transformer = cls(args.source, args.output)
sys.exit(transformer.transform())
if os.path.isdir(args.source):
cls = globals()[TRANSFORMERS[args.toplevel]]
transformer = cls(args.source, args.output)
sys.exit(transformer.transform())
else:
transformer = XMLFileTransformer(args.source, args.toplevel)
xml = transformer.transform()
with open(args.output, 'w') as fd:
fd.write(xml)
sys.exit(0)
if __name__ == "__main__":

Loading…
Cancel
Save