Skip to content

Commit e62b4eb

Browse files
Merge #6555: backport: Merge bitcoin#24263: doc: Fix gen-manpages, rewrite in Python
69b1328 Merge bitcoin#24263: doc: Fix gen-manpages, rewrite in Python (fanquake) Pull request description: ## Issue being fixed or feature implemented gen-pages.sh doesn't work correctly for `dash-cli`, it removes all hyphens somehow: ```diff .IP Set a whitelist to filter incoming RPC calls for a specific user. The field <whitelist> comes in the format: <USERNAME>:<rpc 1>,<rpc 2>,...,<rpc n>. If multiple whitelists are set for a given user, -they are set\-intersected. See \fB\-rpcwhitelistdefault\fR documentation +they are setintersected. See \fBrpcwhitelistdefault\fR documentation for information on default whitelist behavior. .HP ``` ## What was done? - backport bitcoin#24263 Rewrite the manual page generation script in Python. This: - solves '-' stripping issue (fixes bitcoin#22681) - makes that a copyright footer is generated correctly again Also change the release process to swap gen-manpages and update RC steps, so that the pages will have the correct rc and/or final version. ## How Has This Been Tested? Produced correct documents for Dash Core v22.1: #6554 ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: PastaPastaPasta: utACK 69b1328; looks correct UdjinM6: utACK 69b1328 kwvg: utACK 69b1328 Tree-SHA512: 01a7a9a8a4ba762e6ff36035a3fb554d998232d62da8c3441b12741e6a3b626c01c581c1ff3f6aa3dcac02e15d62eec7f2a7f94be9399895557cd0a7115424a7
1 parent 53d0ff1 commit e62b4eb

File tree

4 files changed

+76
-55
lines changed

4 files changed

+76
-55
lines changed

contrib/devtools/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ year rather than two hyphenated years.
7676
If the file already has a copyright for `The Dash Core developers`, the
7777
script will exit.
7878

79-
gen-manpages.sh
79+
gen-manpages.py
8080
===============
8181

8282
A small script to automatically create manpages in ../../doc/man by running the release binaries with the -help option.
@@ -87,7 +87,7 @@ repository. To use this tool with out-of-tree builds set `BUILDDIR`. For
8787
example:
8888

8989
```bash
90-
BUILDDIR=$PWD/build contrib/devtools/gen-manpages.sh
90+
BUILDDIR=$PWD/build contrib/devtools/gen-manpages.py
9191
```
9292

9393
github-merge.py

contrib/devtools/gen-manpages.py

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2022 The Bitcoin Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
import os
6+
import subprocess
7+
import sys
8+
import tempfile
9+
10+
BINARIES = [
11+
'src/dashd',
12+
'src/dash-cli',
13+
'src/dash-tx',
14+
'src/dash-wallet',
15+
#'src/dash-util',
16+
'src/qt/dash-qt',
17+
]
18+
19+
# Paths to external utilities.
20+
git = os.getenv('GIT', 'git')
21+
help2man = os.getenv('HELP2MAN', 'help2man')
22+
23+
# If not otherwise specified, get top directory from git.
24+
topdir = os.getenv('TOPDIR')
25+
if not topdir:
26+
r = subprocess.run([git, 'rev-parse', '--show-toplevel'], stdout=subprocess.PIPE, check=True, universal_newlines=True)
27+
topdir = r.stdout.rstrip()
28+
29+
# Get input and output directories.
30+
builddir = os.getenv('BUILDDIR', topdir)
31+
mandir = os.getenv('MANDIR', os.path.join(topdir, 'doc/man'))
32+
33+
# Verify that all the required binaries are usable, and extract copyright
34+
# message in a first pass.
35+
copyright = None
36+
versions = []
37+
for relpath in BINARIES:
38+
abspath = os.path.join(builddir, relpath)
39+
try:
40+
r = subprocess.run([abspath, '--version'], stdout=subprocess.PIPE, universal_newlines=True)
41+
except IOError:
42+
print(f'{abspath} not found or not an executable', file=sys.stderr)
43+
sys.exit(1)
44+
# take first line (which must contain version)
45+
verstr = r.stdout.split('\n')[0]
46+
# last word of line is the actual version e.g. v22.99.0-5c6b3d5b3508
47+
verstr = verstr.split()[-1]
48+
assert verstr.startswith('v')
49+
50+
# Only dash-qt prints the copyright message on --version, so store it specifically.
51+
if relpath == 'src/qt/dash-qt':
52+
copyright = r.stdout.split('\n')[1:]
53+
54+
versions.append((abspath, verstr))
55+
56+
if any(verstr.endswith('-dirty') for (_, verstr) in versions):
57+
print("WARNING: Binaries were built from a dirty tree.")
58+
print('man pages generated from dirty binaries should NOT be committed.')
59+
print('To properly generate man pages, please commit your changes (or discard them), rebuild, then run this script again.')
60+
print()
61+
62+
with tempfile.NamedTemporaryFile('w', suffix='.h2m') as footer:
63+
# Create copyright footer, and write it to a temporary include file.
64+
assert copyright
65+
footer.write('[COPYRIGHT]\n')
66+
footer.write('\n'.join(copyright).strip())
67+
footer.flush()
68+
69+
# Call the binaries through help2man to produce a manual page for each of them.
70+
for (abspath, verstr) in versions:
71+
outname = os.path.join(mandir, os.path.basename(abspath) + '.1')
72+
print(f'Generating {outname}…')
73+
subprocess.run([help2man, '-N', '--version-string=' + verstr, '--include=' + footer.name, '-o', outname, abspath], check=True)

contrib/devtools/gen-manpages.sh

-52
This file was deleted.

doc/release-process.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Release Process
22
====================
33

44
* [ ] Update translations, see [translation_process.md](https://github.com/dashpay/dash/blob/master/doc/translation_process.md#synchronising-translations).
5-
* [ ] Update manpages, see [gen-manpages.sh](https://github.com/dashpay/dash/blob/master/contrib/devtools/README.md#gen-manpagessh).
5+
* [ ] Update manpages (after rebuilding the binaries), see [gen-manpages.py](https://github.com/bitcoin/bitcoin/blob/master/contrib/devtools/README.md#gen-manpagespy).
66

77
Before every minor and major release:
88

0 commit comments

Comments
 (0)