]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-108826: Document `dis` module CLI and rename `_test` function to `main...
authorHugo van Kemenade <hugovk@users.noreply.github.com>
Wed, 11 Oct 2023 20:48:03 +0000 (22:48 +0200)
committerGitHub <noreply@github.com>
Wed, 11 Oct 2023 20:48:03 +0000 (14:48 -0600)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
12 files changed:
Doc/library/asyncio.rst
Doc/library/cmdline.rst [new file with mode: 0644]
Doc/library/compileall.rst
Doc/library/dis.rst
Doc/library/gzip.rst
Doc/library/index.rst
Doc/library/pickletools.rst
Doc/library/profile.rst
Doc/library/py_compile.rst
Doc/library/sysconfig.rst
Lib/dis.py
Misc/NEWS.d/next/Documentation/2023-09-03-13-43-49.gh-issue-108826.KG7abS.rst [new file with mode: 0644]

index c6a046f534e9a12570cf2eb1289ed014d40c520b..c75ab47404c1e4ecb9c058c7bc00b4a20b9bf57a 100644 (file)
@@ -56,6 +56,8 @@ Additionally, there are **low-level** APIs for
 * :ref:`bridge <asyncio-futures>` callback-based libraries and code
   with async/await syntax.
 
+.. _asyncio-cli:
+
 You can experiment with an ``asyncio`` concurrent context in the REPL:
 
 .. code-block:: pycon
diff --git a/Doc/library/cmdline.rst b/Doc/library/cmdline.rst
new file mode 100644 (file)
index 0000000..af137b8
--- /dev/null
@@ -0,0 +1,55 @@
+++++++++++++++++++++++++++++++++++++
+Modules command-line interface (CLI)
+++++++++++++++++++++++++++++++++++++
+
+The following modules have a command-line interface.
+
+* :ref:`ast <ast-cli>`
+* :ref:`asyncio <asyncio-cli>`
+* :mod:`base64`
+* :ref:`calendar <calendar-cli>`
+* :mod:`code`
+* :ref:`compileall <compileall-cli>`
+* :mod:`cProfile`: see :ref:`profile <profile-cli>`
+* :ref:`difflib <difflib-interface>`
+* :ref:`dis <dis-cli>`
+* :mod:`doctest`
+* :mod:`!encodings.rot_13`
+* :mod:`ensurepip`
+* :mod:`filecmp`
+* :mod:`fileinput`
+* :mod:`ftplib`
+* :ref:`gzip <gzip-cli>`
+* :ref:`http.server <http-server-cli>`
+* :mod:`!idlelib`
+* :ref:`inspect <inspect-module-cli>`
+* :ref:`json.tool <json-commandline>`
+* :mod:`mimetypes`
+* :mod:`pdb`
+* :mod:`pickle`
+* :ref:`pickletools <pickletools-cli>`
+* :mod:`platform`
+* :mod:`poplib`
+* :ref:`profile <profile-cli>`
+* :mod:`pstats`
+* :ref:`py_compile <py_compile-cli>`
+* :mod:`pyclbr`
+* :mod:`pydoc`
+* :mod:`quopri`
+* :mod:`runpy`
+* :ref:`site <site-commandline>`
+* :ref:`sysconfig <sysconfig-cli>`
+* :mod:`tabnanny`
+* :ref:`tarfile <tarfile-commandline>`
+* :mod:`!this`
+* :ref:`timeit <timeit-command-line-interface>`
+* :ref:`tokenize <tokenize-cli>`
+* :ref:`trace <trace-cli>`
+* :mod:`turtledemo`
+* :ref:`unittest <unittest-command-line-interface>`
+* :mod:`venv`
+* :mod:`webbrowser`
+* :ref:`zipapp <zipapp-command-line-interface>`
+* :ref:`zipfile <zipfile-commandline>`
+
+See also the :ref:`Python command-line interface <using-on-general>`.
index a1482c9eb889e88224aaa6815eae1bf20c98a9a9..6d16734ddca21e1739161dab9fca32cbc15c3276 100644 (file)
@@ -16,6 +16,8 @@ have write permission to the library directories.
 
 .. include:: ../includes/wasm-notavail.rst
 
+.. _compileall-cli:
+
 Command-line use
 ----------------
 
index f56784e769a3eeb6960be909b4266c6fe166cd50..a12f5937cd379e1ffe76403a002a118caa32b017 100644 (file)
@@ -64,6 +64,32 @@ the following command can be used to display the disassembly of
 
 (The "2" is a line number).
 
+.. _dis-cli:
+
+Command-line interface
+----------------------
+
+The :mod:`dis` module can be invoked as a script from the command line:
+
+.. code-block:: sh
+
+   python -m dis [-h] [-C] [infile]
+
+The following options are accepted:
+
+.. program:: dis
+
+.. cmdoption:: -h, --help
+
+   Display usage and exit.
+
+.. cmdoption:: -C, --show-caches
+
+   Show inline caches.
+
+If :file:`infile` is specified, its disassembled code will be written to stdout.
+Otherwise, disassembly is performed on compiled source code recieved from stdin.
+
 Bytecode analysis
 -----------------
 
index 4d2fa3d4012a1d98c81ae31db36a0e323087418a..fdb546236aeadc584e67befa9576cb6a66c87691 100644 (file)
@@ -246,6 +246,8 @@ Example of how to GZIP compress a binary string::
 
 .. program:: gzip
 
+.. _gzip-cli:
+
 Command Line Interface
 ----------------------
 
index d064b680f9aaa47e0a05146815ed2b3ebda3359c..0b348ae6f5c8c0af9de243e142dda8b02fd3a7c9 100644 (file)
@@ -73,5 +73,6 @@ the `Python Package Index <https://pypi.org>`_.
    language.rst
    windows.rst
    unix.rst
+   cmdline.rst
    superseded.rst
    security_warnings.rst
index c6ff4e6ed3d3b5d70233993d94142b18ef07168e..41930f8cbe8412dda6de3166bd000a263883d0bb 100644 (file)
@@ -17,6 +17,8 @@ are useful for Python core developers who are working on the :mod:`pickle`;
 ordinary users of the :mod:`pickle` module probably won't find the
 :mod:`pickletools` module relevant.
 
+.. _pickletools-cli:
+
 Command line usage
 ------------------
 
index 723f927135a0f4f811236b9954271bbe9a28973a..69274b0c354a25dd0e2cec31802ee0dea997e0d0 100644 (file)
@@ -121,6 +121,8 @@ results to a file by specifying a filename to the :func:`run` function::
 The :class:`pstats.Stats` class reads profile results from a file and formats
 them in various ways.
 
+.. _profile-cli:
+
 The files :mod:`cProfile` and :mod:`profile` can also be invoked as a script to
 profile another script.  For example::
 
index 7272f36d9a5568b078db293bc1edeeec8763f925..38c416f9ad030514e815dca07908279487db5975 100644 (file)
@@ -125,6 +125,7 @@ byte-code cache files in the directory containing the source code.
       This option is useful when the ``.pycs`` are kept up to date by some
       system external to Python like a build system.
 
+.. _py_compile-cli:
 
 Command-Line Interface
 ----------------------
index 17448f2a2abacec5bfa019e6ecd55df4b22ba1fa..2de47cfd36a0f794b927ed3566cc6e15119db130 100644 (file)
@@ -278,6 +278,7 @@ Other functions
 
    Return the path of :file:`Makefile`.
 
+.. _sysconfig-cli:
 
 Using :mod:`sysconfig` as a script
 ----------------------------------
index 5bf52c3e6d3ac3f0ccd80b0ee9b9a5132d174075..196c886f785082f5a68d22dab29c2f54f956c3da 100644 (file)
@@ -759,8 +759,7 @@ class Bytecode:
             return output.getvalue()
 
 
-def _test():
-    """Simple test program to disassemble a file."""
+def main():
     import argparse
 
     parser = argparse.ArgumentParser()
@@ -772,4 +771,4 @@ def _test():
     dis(code)
 
 if __name__ == "__main__":
-    _test()
+    main()
diff --git a/Misc/NEWS.d/next/Documentation/2023-09-03-13-43-49.gh-issue-108826.KG7abS.rst b/Misc/NEWS.d/next/Documentation/2023-09-03-13-43-49.gh-issue-108826.KG7abS.rst
new file mode 100644 (file)
index 0000000..139b8f3
--- /dev/null
@@ -0,0 +1 @@
+:mod:`dis` module command-line interface is now mentioned in documentation.