Skip to content

Commit 2e4f1a3

Browse files
author
Marek Suchánek
authored
Merge pull request #25 from mrksu/master
Fixes for newdoc
2 parents 5af8f9d + f7382db commit 2e4f1a3

File tree

8 files changed

+148
-130
lines changed

8 files changed

+148
-130
lines changed

.tito/packages/python-newdoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.0-1 newdoc/
1+
1.4.2-1 newdoc/

newdoc/BUILDING.adoc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ This creates the new SRPM package in the `/tmp/tito/` directory on your system.
6262
+
6363
When the build finishes, the update is immediately available to users.
6464

65+
. Delete older builds that might break the uploading step:
66+
+
67+
----
68+
$ rm -r build dist
69+
----
70+
6571
. Build the `pip` package:
6672
+
6773
----
@@ -71,7 +77,7 @@ $ python3 setup.py sdist bdist_wheel
7177
. Upload the package to PyPI:
7278
+
7379
----
74-
$ python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
80+
$ python3 -m twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
7581
----
7682

7783

newdoc/CHANGELOG.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
= Changelog of the `newdoc` script
22

3-
== WIP
3+
== v1.4.0, 2019-08-29
44

55
New features:
66

77
* newdoc is now packaged as an RPM on Copr: link:https://copr.fedorainfracloud.org/coprs/mareksu/newdoc/[].
8+
* Templates have been updated to match the upstream modular guidelines.
89

910
== v1.3, 2018-08-22
1011

newdoc/README.md

Lines changed: 0 additions & 119 deletions
This file was deleted.

newdoc/README.rst

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
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+

newdoc/newdoc.spec

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%global srcname newdoc
22

33
Name: python-%{srcname}
4-
Version: 1.4.0
4+
Version: 1.4.2
55
Release: 1%{?dist}
66
Summary: A script to generate assembly and module AsciiDoc files from templates
77

@@ -64,6 +64,14 @@ A script to generate assembly and module AsciiDoc files from templates
6464
%{_bindir}/newdoc
6565

6666
%changelog
67+
* Mon Sep 30 2019 Marek Suchánek <msuchane@redhat.com> 1.4.2-1
68+
- Fix: Remove a redundant, outdated statement to restore assembly context
69+
(msuchane@redhat.com)
70+
71+
* Sat Aug 31 2019 Marek Suchánek <msuchane@redhat.com> 1.4.1-1
72+
- Converted the readme to RST because PyPI literally can't handle anything else
73+
(msuchane@redhat.com)
74+
6775
* Thu Aug 29 2019 Marek Suchánek <msuchane@redhat.com> 1.4.0-1
6876
- Updated the templates to match upstream; Issue#18
6977
(msuchane@redhat.com)

newdoc/newdoc/templates/assembly_title.adoc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ This paragraph is the assembly introduction. It explains what the user will acco
4242
* For more details on writing assemblies, see the link:https://github.com/redhat-documentation/modular-docs#modular-documentation-reference-guide[Modular Documentation Reference Guide].
4343
* Use a consistent system for file names, IDs, and titles. For tips, see _Anchor Names and File Names_ in link:https://github.com/redhat-documentation/modular-docs#modular-documentation-reference-guide[Modular Documentation Reference Guide].
4444

45-
// The following line is necessary to allow assemblies be included in other
46-
// assemblies. It restores the `context` variable to its previous state.
47-
:context: {parent-context-of-${module_id}}
48-
4945
// Restore the context to what it was before this assembly.
5046
ifdef::parent-context-of-${module_id}[:context: {parent-context-of-${module_id}}]
5147
ifndef::parent-context-of-${module_id}[:!context:]

newdoc/setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# coding=utf-8
22
import setuptools
33

4-
with open("README.md", "r") as fh:
4+
with open("README.rst", "r") as fh:
55
long_description = fh.read()
66

77
setuptools.setup(
88
name="newdoc",
9-
version="1.4.0",
9+
version="1.4.2",
1010
license="GPLv3+",
1111
author="Marek Suchánek",
1212
author_email="marek.suchanek@protonmail.com",
1313
description="A script to generate assembly and module AsciiDoc files from templates.",
1414
long_description=long_description,
15-
long_description_content_type="text/markdown",
15+
# long_description_content_type="text/markdown",
1616
url="https://github.com/mrksu/tools/tree/master/newdoc",
1717
packages=setuptools.find_packages(),
1818
entry_points={

0 commit comments

Comments
 (0)