|
| 1 | +########################### |
| 2 | +README: The `newdoc` script |
| 3 | +########################### |
| 4 | + |
| 5 | +This script is used for generating empty module and assembly files when writing Red Hat or Fedora documentation in AsciiDoc. The generated files follow template guidelines set up by the Modular Documentation initiative: https://redhat-documentation.github.io/modular-docs/. |
| 6 | + |
| 7 | +The script is now compatible with both Python 3 (for Fedora and community distributions) and Python 2.7 (for RHEL 7 and macOS). |
| 8 | + |
| 9 | +It hasn't been tested on Windows. |
| 10 | + |
| 11 | + |
| 12 | +============================ |
| 13 | +How do I install the script? |
| 14 | +============================ |
| 15 | + |
| 16 | +* To install ``newdoc`` on Fedora, use the Copr package repository: https://copr.fedorainfracloud.org/coprs/mareksu/newdoc/. See the instructions there. |
| 17 | + |
| 18 | +* On a Linux distribution that includes Python 3, use the ``pip`` package manager, version 3:: |
| 19 | + |
| 20 | + # pip3 install newdoc |
| 21 | + |
| 22 | +* On RHEL 7, CentOS 7, or macOS, use the ``pip`` package manager, version 2:: |
| 23 | + |
| 24 | + # pip install newdoc |
| 25 | + |
| 26 | + |
| 27 | +========================== |
| 28 | +How do I add a new module? |
| 29 | +========================== |
| 30 | + |
| 31 | +1. In the directory where modules are located, use the ``newdoc`` script to create a new file:: |
| 32 | + |
| 33 | + modules-dir]$ newdoc --procedure "Setting up thing" |
| 34 | + |
| 35 | +2. Rewrite the information in the template with your docs. |
| 36 | + |
| 37 | +The script also accepts the ``--concept`` and ``--reference`` options. You can use these short forms instead: ``-p``, ``-c``, and ``-r``. |
| 38 | + |
| 39 | + |
| 40 | +============================ |
| 41 | +How do I add a new assembly? |
| 42 | +============================ |
| 43 | + |
| 44 | +1. In the directory where assemblies are located, use the ``newdoc`` script to create a new file:: |
| 45 | + |
| 46 | + assemblies-dir]$ newdoc --assembly "Achieving thing" |
| 47 | + |
| 48 | +2. Rewrite the information in the template with your docs. |
| 49 | + |
| 50 | + Add AsciiDoc include statements to include modules. See `Include Files <https://asciidoctor.org/docs/asciidoc-syntax-quick-reference/#include-files>`_ in the AsciiDoc Syntax Quick Reference. |
| 51 | + |
| 52 | +You can use the short form of the ``--assembly`` option instead: ``newdoc -a "Achieving thing"``. |
| 53 | + |
| 54 | + |
| 55 | +============= |
| 56 | +Configuration |
| 57 | +============= |
| 58 | + |
| 59 | +``newdoc`` enables you to configure multiple aspects of its behavior: |
| 60 | + |
| 61 | +* Custom templates for assemblies and modules, |
| 62 | +* How IDs are capitalized when converted from a title, |
| 63 | +* What symbol is used to replace spaces in IDs. |
| 64 | + |
| 65 | +These options can be set in the ``newdoc.ini`` configuration file, which is located: |
| 66 | + |
| 67 | +* On Fedora, RHEL, and other Linux distributions, in ``~/.config/newdoc/newdoc.ini`` |
| 68 | +* On macOS, in ``~/Library/Preferences/newdoc/newdoc.ini`` |
| 69 | + |
| 70 | +The configuration file is not created automatically: if you want to set custom options, create it using a plain text editor. |
| 71 | + |
| 72 | +The file must always start with the ``[newdoc]`` header. An example configuration is available in this repo at ``examples/newdoc.ini``. |
| 73 | + |
| 74 | + |
| 75 | +---------------- |
| 76 | +Custom templates |
| 77 | +---------------- |
| 78 | + |
| 79 | +In the config file, you can set paths to custom AsciiDoc template files for each module type. The options are: |
| 80 | + |
| 81 | +* ``assembly_template`` |
| 82 | +* ``concept_template`` |
| 83 | +* ``procedure_template`` |
| 84 | +* ``reference_template`` |
| 85 | + |
| 86 | +For example, to use a custom template for reference modules, use:: |
| 87 | + |
| 88 | + reference_template = ~/.config/newdoc/my-reference-template.adoc |
| 89 | + |
| 90 | +``newdoc`` performs substitutions on the templates using the Python ``string.template`` library. The following strings are replaced: |
| 91 | + |
| 92 | +* ``${module_title}`` with the entered title of the module |
| 93 | +* ``${module_id}`` with the generated ID of the module |
| 94 | +* ``${filename}`` with the generated file name of the module |
| 95 | + |
| 96 | +For more details on the template syntax, see: https://docs.python.org/3/library/string.html#template-strings |
| 97 | + |
| 98 | + |
| 99 | +---------------- |
| 100 | +ID substitutions |
| 101 | +---------------- |
| 102 | + |
| 103 | +* The ``id_case`` option in the config file controls how the letter case should change from the title to the ID: |
| 104 | + |
| 105 | + * ``id_case = lowercase``: All letters in the ID will be lower-case |
| 106 | + * ``id_case = capitalize``: The first letter will be upper-case, the rest lower-case |
| 107 | + * ``id_case = preserve``: Keep the capitalization as entered in the title |
| 108 | + |
| 109 | +* The ``word_separator`` option lets you choose the symbol (or string) used to replace spaces in the ID. The default is a dash:: |
| 110 | + |
| 111 | + word_separator = - |
| 112 | + |
| 113 | +===== |
| 114 | +Notes |
| 115 | +===== |
| 116 | + |
| 117 | +* If you prefer ``newdoc`` to generate file without the explanatory comments, add the ``--no-comments`` or ``-C`` option when creating documents. |
| 118 | + |
| 119 | + |
| 120 | +==================== |
| 121 | +Additional resources |
| 122 | +==================== |
| 123 | + |
| 124 | +* `Modular Documentation Reference Guide <https://redhat-documentation.github.io/modular-docs/>`_ |
| 125 | +* `AsciiDoc Mark-up Quick Reference for Red Hat Documentation <https://redhat-documentation.github.io/asciidoc-markup-conventions/>`_ |
| 126 | + |
0 commit comments