From 8daddd95bd86334dd6d74d0fe00ea34a2555b143 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Fri, 5 Jan 2024 16:24:16 +0200 Subject: [PATCH 1/5] Fix Sphinx warnings in library/pyclbr.rst --- Doc/library/pyclbr.rst | 6 ++++++ Doc/tools/.nitignore | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Doc/library/pyclbr.rst b/Doc/library/pyclbr.rst index 1c40ba4838ca75..1dc62408c58a2c 100644 --- a/Doc/library/pyclbr.rst +++ b/Doc/library/pyclbr.rst @@ -58,6 +58,9 @@ of these classes. Function Objects ---------------- + +.. class:: Function + Class :class:`Function` instances describe functions defined by def statements. They have the following attributes: @@ -108,6 +111,9 @@ statements. They have the following attributes: Class Objects ------------- + +.. class:: Class + Class :class:`Class` instances describe classes defined by class statements. They have the same attributes as Functions and two more. diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore index 05df332fa7c9a8..c4f9b07dc916c9 100644 --- a/Doc/tools/.nitignore +++ b/Doc/tools/.nitignore @@ -67,7 +67,6 @@ Doc/library/pickletools.rst Doc/library/platform.rst Doc/library/plistlib.rst Doc/library/profile.rst -Doc/library/pyclbr.rst Doc/library/pydoc.rst Doc/library/pyexpat.rst Doc/library/readline.rst From b88f0e10224b2136b7ad34193f70dec226c76eb2 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Fri, 5 Jan 2024 16:38:51 +0200 Subject: [PATCH 2/5] Indent attributes inside classes --- Doc/library/pyclbr.rst | 94 +++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/Doc/library/pyclbr.rst b/Doc/library/pyclbr.rst index 1dc62408c58a2c..b9dd9f1a8bba37 100644 --- a/Doc/library/pyclbr.rst +++ b/Doc/library/pyclbr.rst @@ -61,50 +61,50 @@ Function Objects .. class:: Function -Class :class:`Function` instances describe functions defined by def -statements. They have the following attributes: + Class :class:`Function` instances describe functions defined by def + statements. They have the following attributes: -.. attribute:: Function.file + .. attribute:: file - Name of the file in which the function is defined. + Name of the file in which the function is defined. -.. attribute:: Function.module + .. attribute:: module - The name of the module defining the function described. + The name of the module defining the function described. -.. attribute:: Function.name + .. attribute:: name - The name of the function. + The name of the function. -.. attribute:: Function.lineno + .. attribute:: lineno - The line number in the file where the definition starts. + The line number in the file where the definition starts. -.. attribute:: Function.parent + .. attribute:: parent - For top-level functions, None. For nested functions, the parent. + For top-level functions, None. For nested functions, the parent. - .. versionadded:: 3.7 + .. versionadded:: 3.7 -.. attribute:: Function.children + .. attribute:: children - A dictionary mapping names to descriptors for nested functions and - classes. + A dictionary mapping names to descriptors for nested functions and + classes. - .. versionadded:: 3.7 + .. versionadded:: 3.7 -.. attribute:: Function.is_async + .. attribute:: is_async - ``True`` for functions that are defined with the ``async`` prefix, ``False`` otherwise. + ``True`` for functions that are defined with the ``async`` prefix, ``False`` otherwise. - .. versionadded:: 3.10 + .. versionadded:: 3.10 .. _pyclbr-class-objects: @@ -114,56 +114,56 @@ Class Objects .. class:: Class -Class :class:`Class` instances describe classes defined by class -statements. They have the same attributes as Functions and two more. + Class :class:`Class` instances describe classes defined by class + statements. They have the same attributes as Functions and two more. -.. attribute:: Class.file + .. attribute:: file - Name of the file in which the class is defined. + Name of the file in which the class is defined. -.. attribute:: Class.module + .. attribute:: module - The name of the module defining the class described. + The name of the module defining the class described. -.. attribute:: Class.name + .. attribute:: name - The name of the class. + The name of the class. -.. attribute:: Class.lineno + .. attribute:: lineno - The line number in the file where the definition starts. + The line number in the file where the definition starts. -.. attribute:: Class.parent + .. attribute:: parent - For top-level classes, None. For nested classes, the parent. + For top-level classes, None. For nested classes, the parent. - .. versionadded:: 3.7 + .. versionadded:: 3.7 -.. attribute:: Class.children + .. attribute:: children - A dictionary mapping names to descriptors for nested functions and - classes. + A dictionary mapping names to descriptors for nested functions and + classes. - .. versionadded:: 3.7 + .. versionadded:: 3.7 -.. attribute:: Class.super + .. attribute:: super - A list of :class:`Class` objects which describe the immediate base - classes of the class being described. Classes which are named as - superclasses but which are not discoverable by :func:`readmodule_ex` - are listed as a string with the class name instead of as - :class:`Class` objects. + A list of :class:`Class` objects which describe the immediate base + classes of the class being described. Classes which are named as + superclasses but which are not discoverable by :func:`readmodule_ex` + are listed as a string with the class name instead of as + :class:`Class` objects. -.. attribute:: Class.methods + .. attribute:: methods - A dictionary mapping method names to line numbers. This can be - derived from the newer children dictionary, but remains for - back-compatibility. + A dictionary mapping method names to line numbers. This can be + derived from the newer children dictionary, but remains for + back-compatibility. From 4308235fdd6342377422b1218e95422d9bd40b66 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Fri, 5 Jan 2024 16:40:34 +0200 Subject: [PATCH 3/5] Fix readline/readline_ex -> readmodule/readmodule_ex typos --- Doc/whatsnew/3.10.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst index cd86c82caffc56..7dc06e9af694d9 100644 --- a/Doc/whatsnew/3.10.rst +++ b/Doc/whatsnew/3.10.rst @@ -1316,8 +1316,8 @@ pyclbr ------ Add an ``end_lineno`` attribute to the ``Function`` and ``Class`` -objects in the tree returned by :func:`pyclbr.readline` and -:func:`pyclbr.readline_ex`. It matches the existing (start) ``lineno``. +objects in the tree returned by :func:`pyclbr.readmodule` and +:func:`pyclbr.readmodule_ex`. It matches the existing (start) ``lineno``. (Contributed by Aviral Srivastava in :issue:`38307`.) shelve From 56909242967865f0d24158d4745d164c9e3e40e3 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Fri, 5 Jan 2024 17:03:48 +0200 Subject: [PATCH 4/5] Don't refer to target inside target --- Doc/library/pyclbr.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/library/pyclbr.rst b/Doc/library/pyclbr.rst index b9dd9f1a8bba37..c4cc83d9782a8f 100644 --- a/Doc/library/pyclbr.rst +++ b/Doc/library/pyclbr.rst @@ -61,7 +61,7 @@ Function Objects .. class:: Function - Class :class:`Function` instances describe functions defined by def + Class :class:`!Function` instances describe functions defined by def statements. They have the following attributes: @@ -114,7 +114,7 @@ Class Objects .. class:: Class - Class :class:`Class` instances describe classes defined by class + Class :class:`!Class` instances describe classes defined by class statements. They have the same attributes as Functions and two more. @@ -155,11 +155,11 @@ Class Objects .. attribute:: super - A list of :class:`Class` objects which describe the immediate base + A list of :class:`!Class` objects which describe the immediate base classes of the class being described. Classes which are named as superclasses but which are not discoverable by :func:`readmodule_ex` are listed as a string with the class name instead of as - :class:`Class` objects. + :class:`!Class` objects. .. attribute:: methods From a7ceb1ed85f418c2378a73ce9d48a0f69a11cee0 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Fri, 5 Jan 2024 12:07:02 -0700 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: Alex Waygood --- Doc/library/pyclbr.rst | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Doc/library/pyclbr.rst b/Doc/library/pyclbr.rst index c4cc83d9782a8f..1e9876849b02f3 100644 --- a/Doc/library/pyclbr.rst +++ b/Doc/library/pyclbr.rst @@ -87,14 +87,14 @@ Function Objects .. attribute:: parent - For top-level functions, None. For nested functions, the parent. + For top-level functions, ``None``. For nested functions, the parent. .. versionadded:: 3.7 .. attribute:: children - A dictionary mapping names to descriptors for nested functions and + A :class:`dictionary ` mapping names to descriptors for nested functions and classes. .. versionadded:: 3.7 @@ -102,7 +102,8 @@ Function Objects .. attribute:: is_async - ``True`` for functions that are defined with the ``async`` prefix, ``False`` otherwise. + ``True`` for functions that are defined with the + :keyword:`async ` prefix, ``False`` otherwise. .. versionadded:: 3.10 @@ -115,7 +116,8 @@ Class Objects .. class:: Class Class :class:`!Class` instances describe classes defined by class - statements. They have the same attributes as Functions and two more. + statements. They have the same attributes as :class:`Functions ` + and two more. .. attribute:: file @@ -164,6 +166,7 @@ Class Objects .. attribute:: methods - A dictionary mapping method names to line numbers. This can be - derived from the newer children dictionary, but remains for + A :class:`dictionary ` mapping method names to line numbers. + This can be derived from the newer :attr:`children` dictionary, + but remains for back-compatibility.