public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-9969] libstdc++: Format Python docstrings according to PEP 357
@ 2023-11-13 15:44 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2023-11-13 15:44 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:2558066fa81ae5c7a2d273ce427dd9e127258815

commit r12-9969-g2558066fa81ae5c7a2d273ce427dd9e127258815
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Sep 28 11:06:02 2023 +0100

    libstdc++: Format Python docstrings according to PEP 357
    
    libstdc++-v3/ChangeLog:
    
            * python/libstdcxx/v6/printers.py: Format docstrings according
            to PEP 257.
            * python/libstdcxx/v6/xmethods.py: Likewise.
    
    (cherry picked from commit 0ef4cc8225f8669463bca501f36b6951967a692a)

Diff:
---
 libstdc++-v3/python/libstdcxx/v6/printers.py | 149 ++++++++++++++-------------
 libstdc++-v3/python/libstdcxx/v6/xmethods.py |  32 +++---
 2 files changed, 98 insertions(+), 83 deletions(-)

diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 8d932867051..46361fcd405 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -110,7 +110,7 @@ _versioned_namespace = '__8::'
 
 def lookup_templ_spec(templ, *args):
     """
-    Lookup template specialization templ<args...>
+    Lookup template specialization templ<args...>.
     """
     t = '{}<{}>'.format(templ, ', '.join([str(a) for a in args]))
     try:
@@ -130,17 +130,23 @@ def lookup_templ_spec(templ, *args):
 # Use this to find container node types instead of find_type,
 # see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91997 for details.
 
-
 def lookup_node_type(nodename, containertype):
     """
-    Lookup specialization of template NODENAME corresponding to CONTAINERTYPE.
-    e.g. if NODENAME is '_List_node' and CONTAINERTYPE is std::list<int>
-    then return the type std::_List_node<int>.
-    Returns None if not found.
+    Lookup specialization of template nodename corresponding to containertype.
+
+    nodename - The name of a class template, as a String
+    containertype - The container, as a gdb.Type
+
+    Return a gdb.Type for the corresponding specialization of nodename,
+    or None if the type cannot be found.
+
+    e.g. lookup_node_type('_List_node', gdb.lookup_type('std::list<int>'))
+    will return a gdb.Type for the type std::_List_node<int>.
     """
     # If nodename is unqualified, assume it's in namespace std.
     if '::' not in nodename:
         nodename = 'std::' + nodename
+    # Use either containertype's value_type or its first template argument.
     try:
         valtype = find_type(containertype, 'value_type')
     except:
@@ -193,7 +199,7 @@ def strip_versioned_namespace(typename):
 
 
 def strip_inline_namespaces(type_str):
-    "Remove known inline namespaces from the canonical name of a type."
+    """Remove known inline namespaces from the canonical name of a type."""
     type_str = strip_versioned_namespace(type_str)
     type_str = type_str.replace('std::__cxx11::', 'std::')
     expt_ns = 'std::experimental::'
@@ -205,7 +211,7 @@ def strip_inline_namespaces(type_str):
 
 
 def get_template_arg_list(type_obj):
-    "Return a type's template arguments as a list"
+    """Return a type's template arguments as a list."""
     n = 0
     template_args = []
     while True:
@@ -217,7 +223,7 @@ def get_template_arg_list(type_obj):
 
 
 class SmartPtrIterator(Iterator):
-    "An iterator for smart pointer types with a single 'child' value"
+    """An iterator for smart pointer types with a single 'child' value."""
 
     def __init__(self, val):
         self.val = val
@@ -233,7 +239,9 @@ class SmartPtrIterator(Iterator):
 
 
 class SharedPointerPrinter:
-    "Print a shared_ptr, weak_ptr, atomic<shared_ptr>, or atomic<weak_ptr>"
+    """
+    Print a shared_ptr, weak_ptr, atomic<shared_ptr>, or atomic<weak_ptr>.
+    """
 
     def __init__(self, typename, val):
         self.typename = strip_versioned_namespace(typename)
@@ -271,7 +279,7 @@ class SharedPointerPrinter:
 
 
 def _tuple_impl_get(val):
-    "Return the tuple element stored in a _Tuple_impl<N, T> base class."
+    """Return the tuple element stored in a _Tuple_impl<N, T> base class."""
     bases = val.type.fields()
     if not bases[-1].is_base_class:
         raise ValueError(
@@ -295,7 +303,7 @@ def _tuple_impl_get(val):
 
 
 def tuple_get(n, val):
-    "Return the result of std::get<n>(val) on a std::tuple"
+    """Return the result of std::get<n>(val) on a std::tuple."""
     tuple_size = len(get_template_arg_list(val.type))
     if n > tuple_size:
         raise ValueError("Out of range index for std::get<N> on std::tuple")
@@ -309,7 +317,7 @@ def tuple_get(n, val):
 
 
 def unique_ptr_get(val):
-    "Return the result of val.get() on a std::unique_ptr"
+    """Return the result of val.get() on a std::unique_ptr."""
     # std::unique_ptr<T, D> contains a std::tuple<D::pointer, D>,
     # either as a direct data member _M_t (the old implementation)
     # or within a data member of type __uniq_ptr_data.
@@ -327,7 +335,7 @@ def unique_ptr_get(val):
 
 
 class UniquePointerPrinter:
-    "Print a unique_ptr"
+    """Print a unique_ptr."""
 
     def __init__(self, typename, val):
         self.val = val
@@ -340,12 +348,12 @@ class UniquePointerPrinter:
 
 
 def get_value_from_aligned_membuf(buf, valtype):
-    """Returns the value held in a __gnu_cxx::__aligned_membuf."""
+    """Return the value held in a __gnu_cxx::__aligned_membuf."""
     return buf['_M_storage'].address.cast(valtype.pointer()).dereference()
 
 
 def get_value_from_list_node(node):
-    """Returns the value held in an _List_node<_Val>"""
+    """Return the value held in an _List_node<_Val>."""
     try:
         member = node.type.fields()[1].name
         if member == '_M_data':
@@ -361,7 +369,7 @@ def get_value_from_list_node(node):
 
 
 class StdListPrinter:
-    "Print a std::list"
+    """Print a std::list."""
 
     class _iterator(Iterator):
         def __init__(self, nodetype, head):
@@ -413,14 +421,14 @@ class NodeIteratorPrinter:
 
 
 class StdListIteratorPrinter(NodeIteratorPrinter):
-    "Print std::list::iterator"
+    """Print std::list::iterator."""
 
     def __init__(self, typename, val):
         NodeIteratorPrinter.__init__(self, typename, val, 'list', '_List_node')
 
 
 class StdFwdListIteratorPrinter(NodeIteratorPrinter):
-    "Print std::forward_list::iterator"
+    """Print std::forward_list::iterator."""
 
     def __init__(self, typename, val):
         NodeIteratorPrinter.__init__(self, typename, val, 'forward_list',
@@ -428,7 +436,7 @@ class StdFwdListIteratorPrinter(NodeIteratorPrinter):
 
 
 class StdSlistPrinter:
-    "Print a __gnu_cxx::slist"
+    """Print a __gnu_cxx::slist."""
 
     class _iterator(Iterator):
         def __init__(self, nodetype, head):
@@ -462,7 +470,7 @@ class StdSlistPrinter:
 
 
 class StdSlistIteratorPrinter:
-    "Print __gnu_cxx::slist::iterator"
+    """Print __gnu_cxx::slist::iterator."""
 
     def __init__(self, typename, val):
         self.val = val
@@ -476,7 +484,7 @@ class StdSlistIteratorPrinter:
 
 
 class StdVectorPrinter:
-    "Print a std::vector"
+    """Print a std::vector."""
 
     class _iterator(Iterator):
         def __init__(self, start, finish, bitvec):
@@ -548,7 +556,7 @@ class StdVectorPrinter:
 
 
 class StdVectorIteratorPrinter:
-    "Print std::vector::iterator"
+    """Print std::vector::iterator."""
 
     def __init__(self, typename, val):
         self.val = val
@@ -560,7 +568,7 @@ class StdVectorIteratorPrinter:
 
 
 class StdBitIteratorPrinter:
-    "Print std::vector<bool>'s _Bit_iterator and _Bit_const_iterator"
+    """Print std::vector<bool>'s _Bit_iterator and _Bit_const_iterator."""
 
     def __init__(self, typename, val):
         self.val = val
@@ -572,7 +580,7 @@ class StdBitIteratorPrinter:
 
 
 class StdBitReferencePrinter:
-    "Print std::vector<bool>::reference"
+    """Print std::vector<bool>::reference."""
 
     def __init__(self, typename, val):
         self.val = val
@@ -584,7 +592,7 @@ class StdBitReferencePrinter:
 
 
 class StdTuplePrinter:
-    "Print a std::tuple"
+    """Print a std::tuple."""
 
     class _iterator(Iterator):
         @staticmethod
@@ -669,7 +677,7 @@ class StdTuplePrinter:
 
 
 class StdStackOrQueuePrinter:
-    "Print a std::stack or std::queue"
+    """Print a std::stack or std::queue."""
 
     def __init__(self, typename, val):
         self.typename = strip_versioned_namespace(typename)
@@ -729,7 +737,7 @@ class RbtreeIterator(Iterator):
 
 
 def get_value_from_Rb_tree_node(node):
-    """Returns the value held in an _Rb_tree_node<_Val>"""
+    """Return the value held in an _Rb_tree_node<_Val>."""
     try:
         member = node.type.fields()[1].name
         if member == '_M_value_field':
@@ -749,7 +757,7 @@ def get_value_from_Rb_tree_node(node):
 
 
 class StdRbtreeIteratorPrinter:
-    "Print std::map::iterator, std::set::iterator, etc."
+    """Print std::map::iterator, std::set::iterator, etc."""
 
     def __init__(self, typename, val):
         self.val = val
@@ -764,7 +772,7 @@ class StdRbtreeIteratorPrinter:
 
 
 class StdDebugIteratorPrinter:
-    "Print a debug enabled version of an iterator"
+    """Print a debug enabled version of an iterator."""
 
     def __init__(self, typename, val):
         self.val = val
@@ -788,7 +796,7 @@ def num_elements(num):
 
 
 class StdMapPrinter:
-    "Print a std::map or std::multimap"
+    """Print a std::map or std::multimap."""
 
     # Turn an RbtreeIterator into a pretty-print iterator.
     class _iter(Iterator):
@@ -830,7 +838,7 @@ class StdMapPrinter:
 
 
 class StdSetPrinter:
-    "Print a std::set or std::multiset"
+    """Print a std::set or std::multiset."""
 
     # Turn an RbtreeIterator into a pretty-print iterator.
     class _iter(Iterator):
@@ -866,7 +874,7 @@ class StdSetPrinter:
 
 
 class StdBitsetPrinter:
-    "Print a std::bitset"
+    """Print a std::bitset."""
 
     def __init__(self, typename, val):
         self.typename = strip_versioned_namespace(typename)
@@ -913,7 +921,7 @@ class StdBitsetPrinter:
 
 
 class StdDequePrinter:
-    "Print a std::deque"
+    """Print a std::deque."""
 
     class _iter(Iterator):
         def __init__(self, node, start, end, last, buffer_size):
@@ -978,7 +986,7 @@ class StdDequePrinter:
 
 
 class StdDequeIteratorPrinter:
-    "Print std::deque::iterator"
+    """Print std::deque::iterator."""
 
     def __init__(self, typename, val):
         self.val = val
@@ -990,7 +998,7 @@ class StdDequeIteratorPrinter:
 
 
 class StdStringPrinter:
-    "Print a std::basic_string of some kind"
+    """Print a std::basic_string of some kind."""
 
     def __init__(self, typename, val):
         self.val = val
@@ -1077,7 +1085,7 @@ class StdHashtableIterator(Iterator):
 
 
 class Tr1UnorderedSetPrinter:
-    "Print a std::unordered_set or tr1::unordered_set"
+    """Print a std::unordered_set or tr1::unordered_set."""
 
     def __init__(self, typename, val):
         self.typename = strip_versioned_namespace(typename)
@@ -1104,7 +1112,7 @@ class Tr1UnorderedSetPrinter:
 
 
 class Tr1UnorderedMapPrinter:
-    "Print a std::unordered_map or tr1::unordered_map"
+    """Print a std::unordered_map or tr1::unordered_map."""
 
     def __init__(self, typename, val):
         self.typename = strip_versioned_namespace(typename)
@@ -1151,7 +1159,7 @@ class Tr1UnorderedMapPrinter:
 
 
 class StdForwardListPrinter:
-    "Print a std::forward_list"
+    """Print a std::forward_list."""
 
     class _iterator(Iterator):
         def __init__(self, nodetype, head):
@@ -1188,7 +1196,7 @@ class StdForwardListPrinter:
 
 
 class SingleObjContainerPrinter(object):
-    "Base class for printers of containers of single objects"
+    """Base class for printers of containers of single objects."""
 
     def __init__(self, val, viz, hint=None):
         self.contained_value = val
@@ -1196,7 +1204,7 @@ class SingleObjContainerPrinter(object):
         self.hint = hint
 
     def _recognize(self, type):
-        """Return TYPE as a string after applying type printers"""
+        """Return type as a string after applying type printers."""
         global _use_type_printing
         if not _use_type_printing:
             return str(type)
@@ -1232,8 +1240,8 @@ class SingleObjContainerPrinter(object):
 
 
 def function_pointer_to_name(f):
-    "Find the name of the function referred to by the gdb.Value f, "
-    " which should contain a function pointer from the program."
+    """Find the name of the function referred to by the gdb.Value f,
+    which should contain a function pointer from the program."""
 
     # Turn the function pointer into an actual address.
     # This is needed to unpack ppc64 function descriptors.
@@ -1256,7 +1264,7 @@ def function_pointer_to_name(f):
 
 
 class StdExpAnyPrinter(SingleObjContainerPrinter):
-    "Print a std::any or std::experimental::any"
+    """Print a std::any or std::experimental::any."""
 
     def __init__(self, typename, val):
         self.typename = strip_versioned_namespace(typename)
@@ -1337,7 +1345,7 @@ class StdExpAnyPrinter(SingleObjContainerPrinter):
 
 
 class StdExpOptionalPrinter(SingleObjContainerPrinter):
-    "Print a std::optional or std::experimental::optional"
+    """Print a std::optional or std::experimental::optional."""
 
     def __init__(self, typename, val):
         valtype = self._recognize(val.type.template_argument(0))
@@ -1373,7 +1381,7 @@ class StdExpOptionalPrinter(SingleObjContainerPrinter):
 
 
 class StdVariantPrinter(SingleObjContainerPrinter):
-    "Print a std::variant"
+    """Print a std::variant."""
 
     def __init__(self, typename, val):
         alternatives = get_template_arg_list(val.type)
@@ -1403,7 +1411,7 @@ class StdVariantPrinter(SingleObjContainerPrinter):
 
 
 class StdNodeHandlePrinter(SingleObjContainerPrinter):
-    "Print a container node handle"
+    """Print a container node handle."""
 
     def __init__(self, typename, val):
         self.value_type = val.type.template_argument(1)
@@ -1447,7 +1455,9 @@ class StdNodeHandlePrinter(SingleObjContainerPrinter):
 
 
 class StdExpStringViewPrinter:
-    "Print a std::basic_string_view or std::experimental::basic_string_view"
+    """
+    Print a std::basic_string_view or std::experimental::basic_string_view
+    """
 
     def __init__(self, typename, val):
         self.val = val
@@ -1464,7 +1474,7 @@ class StdExpStringViewPrinter:
 
 
 class StdExpPathPrinter:
-    "Print a std::experimental::filesystem::path"
+    """Print a std::experimental::filesystem::path."""
 
     def __init__(self, typename, val):
         self.val = val
@@ -1517,7 +1527,7 @@ class StdExpPathPrinter:
 
 
 class StdPathPrinter:
-    "Print a std::filesystem::path"
+    """Print a std::filesystem::path."""
 
     def __init__(self, typename, val):
         self.val = val
@@ -1590,13 +1600,13 @@ class StdPathPrinter:
 
 
 class StdPairPrinter:
-    "Print a std::pair object, with 'first' and 'second' as children"
+    """Print a std::pair object, with 'first' and 'second' as children."""
 
     def __init__(self, typename, val):
         self.val = val
 
     class _iter(Iterator):
-        "An iterator for std::pair types. Returns 'first' then 'second'."
+        """An iterator for std::pair types. Returns 'first' then 'second'."""
 
         def __init__(self, val):
             self.val = val
@@ -1623,7 +1633,7 @@ class StdPairPrinter:
 
 
 class StdCmpCatPrinter:
-    "Print a comparison category object"
+    """Print a comparison category object."""
 
     def __init__(self, typename, val):
         self.typename = typename[typename.rfind(':')+1:]
@@ -1639,7 +1649,7 @@ class StdCmpCatPrinter:
 
 
 class StdErrorCodePrinter:
-    "Print a std::error_code or std::error_condition"
+    """Print a std::error_code or std::error_condition."""
 
     _system_is_posix = None  # Whether std::system_category() use errno values.
 
@@ -1729,7 +1739,9 @@ class StdErrorCodePrinter:
 
     @staticmethod
     def _unqualified_name(name):
-        "Strip any nested-name-specifier from NAME to give an unqualified name"
+        """
+        Strip any nested-name-specifier from name to give an unqualified name.
+        """
         return name.split('::')[-1]
 
     def to_string(self):
@@ -1759,7 +1771,7 @@ class StdErrorCodePrinter:
 
 
 class StdRegexStatePrinter:
-    "Print a state node in the NFA for a std::regex"
+    """Print a state node in the NFA for a std::regex."""
 
     def __init__(self, typename, val):
         self.val = val
@@ -1788,7 +1800,7 @@ class StdRegexStatePrinter:
 
 
 class StdSpanPrinter:
-    "Print a std::span"
+    """Print a std::span."""
 
     class iterator(Iterator):
         def __init__(self, begin, size):
@@ -1826,7 +1838,7 @@ class StdSpanPrinter:
 
 
 class StdInitializerListPrinter:
-    "Print a std::initializer_list"
+    """Print a std::initializer_list."""
 
     def __init__(self, typename, val):
         self.typename = typename
@@ -1844,7 +1856,7 @@ class StdInitializerListPrinter:
 
 
 class StdAtomicPrinter:
-    "Print a std:atomic"
+    """Print a std:atomic."""
 
     def __init__(self, typename, val):
         self.typename = strip_versioned_namespace(typename)
@@ -1971,14 +1983,14 @@ libstdcxx_printer = None
 
 
 class TemplateTypePrinter(object):
-    r"""
+    """
     A type printer for class templates with default template arguments.
 
     Recognizes specializations of class templates and prints them without
     any template arguments that use a default template argument.
     Type printers are recursively applied to the template arguments.
 
-    e.g. replace "std::vector<T, std::allocator<T> >" with "std::vector<T>".
+    e.g. replace 'std::vector<T, std::allocator<T> >' with 'std::vector<T>'.
     """
 
     def __init__(self, name, defargs):
@@ -1987,7 +1999,7 @@ class TemplateTypePrinter(object):
         self.enabled = True
 
     class _recognizer(object):
-        "The recognizer class for TemplateTypePrinter."
+        """The recognizer class for TemplateTypePrinter."""
 
         def __init__(self, name, defargs):
             self.name = name
@@ -2067,12 +2079,12 @@ class TemplateTypePrinter(object):
             return str(type_obj)
 
     def instantiate(self):
-        "Return a recognizer object for this type printer."
+        """Return a recognizer object for this type printer."""
         return self._recognizer(self.name, self.defargs)
 
 
 def add_one_template_type_printer(obj, name, defargs):
-    r"""
+    """
     Add a type printer for a class template with default template arguments.
 
     Args:
@@ -2086,7 +2098,6 @@ def add_one_template_type_printer(obj, name, defargs):
     { 2: 'std::hash<{0}>',
       3: 'std::equal_to<{0}>',
       4: 'std::allocator<std::pair<const {0}, {1}> >' }
-
     """
     printer = TemplateTypePrinter('std::'+name, defargs)
     gdb.types.register_type_printer(obj, printer)
@@ -2105,7 +2116,7 @@ def add_one_template_type_printer(obj, name, defargs):
         gdb.types.register_type_printer(obj, printer)
 
 class FilteringTypePrinter(object):
-    r"""
+    """
     A type printer that uses typedef names for common template specializations.
 
     Args:
@@ -2130,7 +2141,7 @@ class FilteringTypePrinter(object):
         self.enabled = True
 
     class _recognizer(object):
-        "The recognizer class for FilteringTypePrinter."
+        """The recognizer class for FilteringTypePrinter."""
 
         def __init__(self, template, name, targ1):
             self.template = template
@@ -2174,7 +2185,7 @@ class FilteringTypePrinter(object):
             return None
 
     def instantiate(self):
-        "Return a recognizer object for this type printer."
+        """Return a recognizer object for this type printer."""
         return self._recognizer(self.template, self.name, self.targ1)
 
 
@@ -2299,7 +2310,7 @@ def register_type_printers(obj):
 
 
 def register_libstdcxx_printers(obj):
-    "Register libstdc++ pretty-printers with objfile Obj."
+    """Register libstdc++ pretty-printers with objfile Obj."""
 
     global _use_gdb_pp
     global libstdcxx_printer
diff --git a/libstdc++-v3/python/libstdcxx/v6/xmethods.py b/libstdc++-v3/python/libstdcxx/v6/xmethods.py
index 77a506a4b39..639526e9a79 100644
--- a/libstdc++-v3/python/libstdcxx/v6/xmethods.py
+++ b/libstdc++-v3/python/libstdcxx/v6/xmethods.py
@@ -607,7 +607,9 @@ class AssociativeContainerMethodsMatcher(gdb.xmethod.XMethodMatcher):
 
 
 class UniquePtrGetWorker(gdb.xmethod.XMethodWorker):
-    "Implements std::unique_ptr<T>::get() and std::unique_ptr<T>::operator->()"
+    """
+    Implement std::unique_ptr<T>::get() and std::unique_ptr<T>::operator->().
+    """
 
     def __init__(self, elem_type):
         self._is_array = elem_type.code == gdb.TYPE_CODE_ARRAY
@@ -623,7 +625,7 @@ class UniquePtrGetWorker(gdb.xmethod.XMethodWorker):
         return self._elem_type.pointer()
 
     def _supports(self, method_name):
-        "operator-> is not supported for unique_ptr<T[]>"
+        # operator-> is not supported for unique_ptr<T[]>
         return method_name == 'get' or not self._is_array
 
     def __call__(self, obj):
@@ -647,7 +649,7 @@ class UniquePtrGetWorker(gdb.xmethod.XMethodWorker):
 
 
 class UniquePtrDerefWorker(UniquePtrGetWorker):
-    "Implements std::unique_ptr<T>::operator*()"
+    """Implement std::unique_ptr<T>::operator*()."""
 
     def __init__(self, elem_type):
         UniquePtrGetWorker.__init__(self, elem_type)
@@ -656,7 +658,7 @@ class UniquePtrDerefWorker(UniquePtrGetWorker):
         return self._elem_type
 
     def _supports(self, method_name):
-        "operator* is not supported for unique_ptr<T[]>"
+        # operator* is not supported for unique_ptr<T[]>
         return not self._is_array
 
     def __call__(self, obj):
@@ -664,7 +666,7 @@ class UniquePtrDerefWorker(UniquePtrGetWorker):
 
 
 class UniquePtrSubscriptWorker(UniquePtrGetWorker):
-    "Implements std::unique_ptr<T>::operator[](size_t)"
+    """Implement std::unique_ptr<T>::operator[](size_t)."""
 
     def __init__(self, elem_type):
         UniquePtrGetWorker.__init__(self, elem_type)
@@ -676,7 +678,7 @@ class UniquePtrSubscriptWorker(UniquePtrGetWorker):
         return self._elem_type
 
     def _supports(self, method_name):
-        "operator[] is only supported for unique_ptr<T[]>"
+        # operator[] is only supported for unique_ptr<T[]>
         return self._is_array
 
     def __call__(self, obj, index):
@@ -710,7 +712,9 @@ class UniquePtrMethodsMatcher(gdb.xmethod.XMethodMatcher):
 
 
 class SharedPtrGetWorker(gdb.xmethod.XMethodWorker):
-    "Implements std::shared_ptr<T>::get() and std::shared_ptr<T>::operator->()"
+    """
+    Implements std::shared_ptr<T>::get() and std::shared_ptr<T>::operator->().
+    """
 
     def __init__(self, elem_type):
         self._is_array = elem_type.code == gdb.TYPE_CODE_ARRAY
@@ -726,7 +730,7 @@ class SharedPtrGetWorker(gdb.xmethod.XMethodWorker):
         return self._elem_type.pointer()
 
     def _supports(self, method_name):
-        "operator-> is not supported for shared_ptr<T[]>"
+        # operator-> is not supported for shared_ptr<T[]>
         return method_name == 'get' or not self._is_array
 
     def __call__(self, obj):
@@ -734,7 +738,7 @@ class SharedPtrGetWorker(gdb.xmethod.XMethodWorker):
 
 
 class SharedPtrDerefWorker(SharedPtrGetWorker):
-    "Implements std::shared_ptr<T>::operator*()"
+    """Implement std::shared_ptr<T>::operator*()."""
 
     def __init__(self, elem_type):
         SharedPtrGetWorker.__init__(self, elem_type)
@@ -743,7 +747,7 @@ class SharedPtrDerefWorker(SharedPtrGetWorker):
         return self._elem_type
 
     def _supports(self, method_name):
-        "operator* is not supported for shared_ptr<T[]>"
+        # operator* is not supported for shared_ptr<T[]>
         return not self._is_array
 
     def __call__(self, obj):
@@ -751,7 +755,7 @@ class SharedPtrDerefWorker(SharedPtrGetWorker):
 
 
 class SharedPtrSubscriptWorker(SharedPtrGetWorker):
-    "Implements std::shared_ptr<T>::operator[](size_t)"
+    """Implement std::shared_ptr<T>::operator[](size_t)."""
 
     def __init__(self, elem_type):
         SharedPtrGetWorker.__init__(self, elem_type)
@@ -763,7 +767,7 @@ class SharedPtrSubscriptWorker(SharedPtrGetWorker):
         return self._elem_type
 
     def _supports(self, method_name):
-        "operator[] is only supported for shared_ptr<T[]>"
+        # operator[] is only supported for shared_ptr<T[]>
         return self._is_array
 
     def __call__(self, obj, index):
@@ -776,7 +780,7 @@ class SharedPtrSubscriptWorker(SharedPtrGetWorker):
 
 
 class SharedPtrUseCountWorker(gdb.xmethod.XMethodWorker):
-    "Implements std::shared_ptr<T>::use_count()"
+    """Implement std::shared_ptr<T>::use_count()."""
 
     def __init__(self, elem_type):
         pass
@@ -796,7 +800,7 @@ class SharedPtrUseCountWorker(gdb.xmethod.XMethodWorker):
 
 
 class SharedPtrUniqueWorker(SharedPtrUseCountWorker):
-    "Implements std::shared_ptr<T>::unique()"
+    """Implement std::shared_ptr<T>::unique()."""
 
     def __init__(self, elem_type):
         SharedPtrUseCountWorker.__init__(self, elem_type)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-13 15:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-13 15:44 [gcc r12-9969] libstdc++: Format Python docstrings according to PEP 357 Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).