Skip to content

Commit b9d0a45

Browse files
author
Marek Suchánek
authored
Merge pull request #30 from mrksu/master
Minor updates to newdoc and a deprecation of this version
2 parents 027fbc5 + e2da106 commit b9d0a45

File tree

6 files changed

+34
-67
lines changed

6 files changed

+34
-67
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.3-1 newdoc/
1+
1.5.1-1 newdoc/

newdoc/README.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
###########################
2-
README: The `newdoc` script
3-
###########################
1+
########################################
2+
README: The `newdoc` script (DEPRECATED)
3+
########################################
4+
5+
**DEPRECATED:** This version of `newdoc` is now deprecated and will no longer receive any significant updates. Please uninstall this version and migrate to the current version: https://github.com/redhat-documentation/newdoc.
46

57
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/.
68

newdoc/newdoc.spec

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
11
%global srcname newdoc
22

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

88
License: GPLv3+
99
URL: https://pypi.python.org/pypi/%{srcname}
1010
Source0: %pypi_source
1111

1212
BuildArch: noarch
13-
BuildRequires: python2-devel python3-devel
13+
BuildRequires: python3-devel
1414

1515
%description
1616
A script to generate assembly and module AsciiDoc files from templates
1717

18-
%package -n python2-%{srcname}
19-
Summary: %{summary}
20-
%{?python_provide:%python_provide python2-%{srcname}}
21-
22-
%description -n python2-%{srcname}
23-
A script to generate assembly and module AsciiDoc files from templates
24-
25-
2618
%package -n python3-%{srcname}
2719
Summary: %{summary}
2820
%{?python_provide:%python_provide python3-%{srcname}}
@@ -35,35 +27,33 @@ A script to generate assembly and module AsciiDoc files from templates
3527
%autosetup -n %{srcname}-%{version}
3628

3729
%build
38-
%py2_build
3930
%py3_build
4031

4132
%install
42-
# Must do the python2 install first because the scripts in /usr/bin are
43-
# overwritten with every setup.py install, and in general we want the
44-
# python3 version to be the default.
45-
# If, however, we're installing separate executables for python2 and python3,
46-
# the order needs to be reversed so the unversioned executable is the python2 one.
47-
%py2_install
4833
%py3_install
4934

5035
%check
51-
%{__python2} setup.py test
5236
%{__python3} setup.py test
5337

54-
# Note that there is no %%files section for the unversioned python module if we are building for several python runtimes
55-
%files -n python2-%{srcname}
56-
%license LICENSE
57-
%doc README.rst
58-
%{python2_sitelib}/*
59-
6038
%files -n python3-%{srcname}
6139
%license LICENSE
6240
%doc README.rst
6341
%{python3_sitelib}/*
6442
%{_bindir}/newdoc
6543

6644
%changelog
45+
* Fri Sep 25 2020 Marek Suchánek <[email protected]> 1.5.1-1
46+
- Announce the deprecation of this version and the migration to the new one
47+
48+
49+
* Tue Jun 23 2020 Marek Suchánek <[email protected]> 1.5.0-1
50+
- Remove the remaining Python 2 code ([email protected])
51+
- Align the Optional formatting with the IBM Style Guide; #29
52+
53+
- Remove Python 2 packaging ([email protected])
54+
- Update outdated version information ([email protected])
55+
- Clarify newdoc install instructions ([email protected])
56+
6757
* Mon Oct 07 2019 Marek Suchánek <[email protected]> 1.4.3-1
6858
- Fix a reference to the renamed readme in the RPM spec ([email protected])
6959
- Updated the changelog ([email protected])

newdoc/newdoc/newdoc.py

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,11 @@
77
import argparse
88
from string import Template
99

10-
NEWDOC_VERSION = "1.3.2"
11-
12-
# Record whether we're running under Python 2 or 3
13-
PYVERSION = sys.version_info.major
10+
NEWDOC_VERSION = "1.5.1"
11+
DEPRECATION = "DEPRECATED:\nThis version of `newdoc` is now deprecated and will no longer receive any significant updates.\nPlease uninstall this version and migrate to the current version:\nhttps://github.com/redhat-documentation/newdoc"
1412

1513
# The configparser module is called ConfigParser in Python2
16-
if PYVERSION == 2:
17-
import ConfigParser as cp
18-
else:
19-
import configparser as cp
20-
21-
# Force Python 2 to use the UTF-8 encoding. Otherwise, loading a template
22-
# containing Unicode characters fails.
23-
if PYVERSION == 2:
24-
reload(sys)
25-
sys.setdefaultencoding('utf8')
14+
import configparser as cp
2615

2716
# The directory where the script is located
2817
SCRIPT_HOME_DIR = os.path.dirname(__file__)
@@ -92,7 +81,7 @@ def get_config():
9281

9382
for k in options.keys():
9483
# The configparser library is different in Python 2 and 3.
95-
# This si the only 2/3-compatible way I've found for optional keys.
84+
# This is the only 2/3-compatible way I've found for optional keys.
9685
try:
9786
options[k] = config.get("newdoc", k)
9887
except cp.NoOptionError:
@@ -204,12 +193,6 @@ def write_file(out_file, module_content):
204193
performing necessary checks
205194
"""
206195

207-
# In Python 2, the `input` function is called `raw_input`
208-
if PYVERSION == 2:
209-
compatible_input = raw_input
210-
else:
211-
compatible_input = input
212-
213196
# Check if the file exists; abort if so
214197
if os.path.exists(out_file):
215198
print('File already exists: "{}"'.format(out_file))
@@ -218,7 +201,7 @@ def write_file(out_file, module_content):
218201
decision = None
219202

220203
while not decision:
221-
response = compatible_input("Overwrite it? [yes/no] ").lower()
204+
response = input("Overwrite it? [yes/no] ").lower()
222205

223206
if response in ["yes", "y"]:
224207
print("Overwriting.")
@@ -232,13 +215,8 @@ def write_file(out_file, module_content):
232215
# Write the file
233216
with open(out_file, "w") as f:
234217
f.write(module_content)
235-
# In Python 2, the UTF-8 encoding has to be specified explicitly
236-
if PYVERSION == 2:
237-
with io.open(out_file, mode="w", encoding="utf-8") as f:
238-
f.write(module_content)
239-
else:
240-
with open(out_file, "w") as f:
241-
f.write(module_content)
218+
with open(out_file, "w") as f:
219+
f.write(module_content)
242220

243221
print("File successfully generated.")
244222
print("To include this file from an assembly, use:")
@@ -271,13 +249,8 @@ def create_module(title, doc_type, options, delete_comments):
271249
print("Error: Template file not found: '{}'".format(template_file))
272250
exit(1)
273251

274-
# In Python 2, the UTF-8 encoding has to be specified explicitly
275-
if PYVERSION == 2:
276-
with io.open(template_file, mode="r", encoding="utf-8") as f:
277-
template = f.read()
278-
else:
279-
with open(template_file, "r") as f:
280-
template = f.read()
252+
with open(template_file, "r") as f:
253+
template = f.read()
281254

282255
# Prepare the content of the new module
283256
module_content = Template(template).substitute(module_title=title,
@@ -296,6 +269,8 @@ def main():
296269
"""
297270
Main, executable procedure of the script
298271
"""
272+
print(DEPRECATION, "\n")
273+
299274
# Build a command-line options parser
300275
parser = argparse.ArgumentParser()
301276

newdoc/newdoc/templates/proc_title.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This paragraph is the procedure module introduction: a short description of the
2929

3030
.Verification steps
3131

32-
. (Optional) Provide the user with verification method(s) for the procedure, such as expected output or commands that can be used to check for success or failure.
32+
. Optional: Provide the user with verification method(s) for the procedure, such as expected output or commands that can be used to check for success or failure.
3333
. Use an unnumbered bullet (*) if the procedure includes only one step.
3434

3535
.Additional resources

newdoc/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setuptools.setup(
88
name="newdoc",
9-
version="1.4.3",
9+
version="1.5.1",
1010
license="GPLv3+",
1111
author="Marek Suchánek",
1212
author_email="[email protected]",

0 commit comments

Comments
 (0)