doc: Fix gen-manpages, rewrite in Python #24263

pull laanwj wants to merge 2 commits into bitcoin:master from laanwj:2022-02-gen-manpages changing 4 files +77 −56
  1. laanwj commented at 3:36 PM on February 4, 2022: member

    Rewrite the manual page generation script in Python.

    This:

    • solves '-' stripping issue (fixes #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.

  2. laanwj added the label Docs on Feb 4, 2022
  3. laanwj added this to the milestone 23.0 on Feb 4, 2022
  4. laanwj force-pushed on Feb 4, 2022
  5. laanwj commented at 3:54 PM on February 4, 2022: member

    Does anyone understand this mypy output?

    contrib/devtools/gen-manpages.py:26: error: No overload variant of "run" matches argument types "List[str]", "bool", "bool", "bool"  [call-overload]
    contrib/devtools/gen-manpages.py:26: note: Possible overload variants:
    contrib/devtools/gen-manpages.py:26: note:     def run(args: Union[Union[bytes, str], Sequence[Union[str, bytes, PathLike[str], PathLike[bytes]]]], bufsize: int = ..., executable: Union[str, bytes, PathLike[str], PathLike[bytes], None] = ..., stdin: Union[None, int, IO[Any]] = ..., stdout: Union[None, int, IO[Any]] = ..., stderr: Union[None, int, IO[Any]] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., cwd: Union[str, bytes, PathLike[str], PathLike[bytes], None] = ..., env: Union[Mapping[bytes, Union[str, bytes, PathLike[str], PathLike[bytes]]], Mapping[str, Union[str, bytes, PathLike[str], PathLike[bytes]]], None] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., *, check: bool = ..., encoding: str, errors: Optional[str] = ..., input: Optional[str] = ..., timeout: Optional[float] = ...) -> CompletedProcess[str]
    contrib/devtools/gen-manpages.py:26: note:     def run(args: Union[Union[bytes, str], Sequence[Union[str, bytes, PathLike[str], PathLike[bytes]]]], bufsize: int = ..., executable: Union[str, bytes, PathLike[str], PathLike[bytes], None] = ..., stdin: Union[None, int, IO[Any]] = ..., stdout: Union[None, int, IO[Any]] = ..., stderr: Union[None, int, IO[Any]] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., cwd: Union[str, bytes, PathLike[str], PathLike[bytes], None] = ..., env: Union[Mapping[bytes, Union[str, bytes, PathLike[str], PathLike[bytes]]], Mapping[str, Union[str, bytes, PathLike[str], PathLike[bytes]]], None] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., *, check: bool = ..., encoding: Optional[str] = ..., errors: str, input: Optional[str] = ..., timeout: Optional[float] = ...) -> CompletedProcess[str]
    contrib/devtools/gen-manpages.py:26: note:     <3 more similar overloads not shown, out of 5 total overloads>
    contrib/devtools/gen-manpages.py:31: error: Argument 1 to "join" has incompatible type "Optional[str]"; expected "Union[str, PathLike[str]]"  [arg-type]
    contrib/devtools/gen-manpages.py:38: error: Argument 1 to "join" has incompatible type "Optional[str]"; expected "Union[str, PathLike[str]]"  [arg-type]
    contrib/devtools/gen-manpages.py:40: error: No overload variant of "run" matches argument types "List[str]", "bool", "bool"  [call-overload]
    contrib/devtools/gen-manpages.py:40: note: Possible overload variants:
    contrib/devtools/gen-manpages.py:40: note:     def run(args: Union[Union[bytes, str], Sequence[Union[str, bytes, PathLike[str], PathLike[bytes]]]], bufsize: int = ..., executable: Union[str, bytes, PathLike[str], PathLike[bytes], None] = ..., stdin: Union[None, int, IO[Any]] = ..., stdout: Union[None, int, IO[Any]] = ..., stderr: Union[None, int, IO[Any]] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., cwd: Union[str, bytes, PathLike[str], PathLike[bytes], None] = ..., env: Union[Mapping[bytes, Union[str, bytes, PathLike[str], PathLike[bytes]]], Mapping[str, Union[str, bytes, PathLike[str], PathLike[bytes]]], None] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., *, check: bool = ..., encoding: str, errors: Optional[str] = ..., input: Optional[str] = ..., timeout: Optional[float] = ...) -> CompletedProcess[str]
    contrib/devtools/gen-manpages.py:40: note:     def run(args: Union[Union[bytes, str], Sequence[Union[str, bytes, PathLike[str], PathLike[bytes]]]], bufsize: int = ..., executable: Union[str, bytes, PathLike[str], PathLike[bytes], None] = ..., stdin: Union[None, int, IO[Any]] = ..., stdout: Union[None, int, IO[Any]] = ..., stderr: Union[None, int, IO[Any]] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., cwd: Union[str, bytes, PathLike[str], PathLike[bytes], None] = ..., env: Union[Mapping[bytes, Union[str, bytes, PathLike[str], PathLike[bytes]]], Mapping[str, Union[str, bytes, PathLike[str], PathLike[bytes]]], None] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., creationflags: int = ..., restore_signals: bool = ..., start_new_session: bool = ..., pass_fds: Any = ..., *, check: bool = ..., encoding: Optional[str] = ..., errors: str, input: Optional[str] = ..., timeout: Optional[float] = ...) -> CompletedProcess[str]
    contrib/devtools/gen-manpages.py:40: note:     <3 more similar overloads not shown, out of 5 total overloads>
    

    I can't reproduce it locally with mypy 0.761 and python 3.8.10. I don't think I'm passing anything weird to subprocess.run or path.join.

    Edit: also tried with mypy 0.931. No dice. Edit.2: FIgured it out, I think. capture_output is new in Python 3.7 so too recent.

  6. doc: Fix gen-manpages, rewrite in Python
    Rewrite the manual page generation script in Python.
    
    This:
    - Solves '-' stripping issue (fixes #22681)
    - Makes that copyright footer is generated again
    42c202893b
  7. doc: Swap gen-manpages and update RC steps in release process 87f54060ff
  8. laanwj force-pushed on Feb 4, 2022
  9. DrahtBot commented at 8:50 PM on February 4, 2022: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #22235 (script: add script to generate example bitcoin.conf by josibake)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  10. ghost commented at 9:14 PM on February 4, 2022: none

    Concept ACK

  11. DrahtBot cross-referenced this on Feb 5, 2022 from issue script: add script to generate example bitcoin.conf by josibake
  12. laanwj commented at 8:58 AM on February 5, 2022: member

    Something that is weird, but outside scope of this particular PR to fix. is that the copyright message is emitted inconsistently between binaries:

    binary -help -version
    bitcoind yes no
    bitcoin-cli no no
    bitcoin-tx no no
    bitcoin-wallet no no
    bitcoin-util no no
    bitcoin-qt no yes

    I don't have a strong opinion on whether it should be shown with -version or -help, but it probably should be either, and consistent between binaries.

  13. luke-jr cross-referenced this on Feb 7, 2022 from issue Bugfix: gen-manpages: Handle tagged versions correctly by luke-jr
  14. laanwj commented at 9:52 AM on February 14, 2022: member

    @dongcarl Can I get a concept ACK here at least? It should exactly do what you propose in #22681 (comment)

  15. in contrib/devtools/gen-manpages.py:45 in 87f54060ff
      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]
    


    dongcarl commented at 6:27 PM on February 14, 2022:

    Nit

        verstr = r.stdout.splitlines()[0]
    

    fanquake commented at 9:01 PM on February 21, 2022:

    done in #24409.

  16. in contrib/devtools/gen-manpages.py:40 in 87f54060ff
      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)
    


    dongcarl commented at 6:28 PM on February 14, 2022:

    Any reason not to do check=True here?


    fanquake commented at 8:54 PM on February 21, 2022:

    The script will fail because bitcoin-wallet returns non-0.


    laanwj commented at 8:48 AM on February 22, 2022:

    Yes, I initially did check but as @fanquake says. I'm not sure why bitcoin-wallet does that actually.


    fanquake commented at 10:22 AM on February 23, 2022:

    Addresses in #24428.

  17. dongcarl approved
  18. dongcarl commented at 6:31 PM on February 14, 2022: contributor

    Code Review ACK 87f54060ffffdb56c97594efdca378bace5323df

    Had to remind myself of the situation but everything looks good, just a few nits that are 100% ignore-able.

  19. theStack commented at 7:16 PM on February 20, 2022: contributor

    Concept ACK

  20. gruve-p commented at 9:49 PM on February 20, 2022: contributor

    Concept ACK

  21. fanquake approved
  22. fanquake commented at 2:17 PM on February 21, 2022: member

    ACK 87f54060ffffdb56c97594efdca378bace5323df - tested generating and opening the man pages locally, but didn't run through the release process. Will propose some changes to address consolidating the help / version output.

  23. fanquake merged this on Feb 21, 2022
  24. fanquake closed this on Feb 21, 2022

  25. fanquake referenced this in commit cb8bea5e37 on Feb 21, 2022
  26. fanquake cross-referenced this on Feb 21, 2022 from issue Always output license/copyright info with `-version` by fanquake
  27. fanquake referenced this in commit 0ed0d5dcb2 on Feb 22, 2022
  28. fanquake referenced this in commit 5a89bed410 on Feb 22, 2022
  29. sidhujag referenced this in commit 090a56e493 on Feb 22, 2022
  30. MarcoFalke referenced this in commit 3c565302aa on Feb 23, 2022
  31. fanquake referenced this in commit 93c8b7a4ad on Feb 23, 2022
  32. fanquake referenced this in commit 394fdcc9d6 on Feb 23, 2022
  33. fanquake cross-referenced this on Feb 23, 2022 from issue util: improve bitcoin-wallet exit codes by fanquake
  34. fanquake referenced this in commit 05a0be9546 on Feb 23, 2022
  35. fanquake referenced this in commit dd532ee9c4 on Feb 23, 2022
  36. sidhujag referenced this in commit 4ac249e754 on Feb 23, 2022
  37. MarcoFalke cross-referenced this on Sep 12, 2022 from issue util: improve bitcoin-wallet exit codes by MarcoFalke
  38. MarcoFalke referenced this in commit d76a423809 on Sep 20, 2022
  39. bitcoin locked this on Feb 23, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:53 UTC