11import string
2- from typing import Iterable
2+ from collections . abc import Set
33
44import docutils .nodes as nodes
55
@@ -11,25 +11,11 @@ class DescriptionParser(nodes.NodeVisitor):
1111
1212 def __init__ (
1313 self ,
14+ document : nodes .document ,
15+ * ,
1416 desc_len : int ,
15- known_titles : Iterable [str ] = None ,
16- document : nodes .document = None ,
17+ known_titles : Set [str ] = frozenset (),
1718 ):
18- # Hack to prevent requirement for the doctree to be passed in.
19- # It's only used by doctree.walk(...) to print debug messages.
20- if document is None :
21-
22- class document_cls :
23- class reporter :
24- @staticmethod
25- def debug (* args , ** kwaargs ):
26- pass
27-
28- document = document_cls ()
29-
30- if known_titles == None :
31- known_titles = []
32-
3319 super ().__init__ (document )
3420 self .description = ""
3521 self .desc_len = desc_len
@@ -115,9 +101,10 @@ def dispatch_departure(self, node: nodes.Element) -> None:
115101def get_description (
116102 doctree : nodes .document ,
117103 description_length : int ,
118- known_titles : Iterable [str ] = None ,
119- document : nodes .document = None ,
104+ known_titles : Set [str ] = frozenset (),
120105):
121- mcv = DescriptionParser (description_length , known_titles , document )
106+ mcv = DescriptionParser (
107+ doctree , desc_len = description_length , known_titles = known_titles
108+ )
122109 doctree .walkabout (mcv )
123110 return mcv .description
0 commit comments