@@ -158,35 +158,18 @@ def __getstate__(self) -> Dict[str,Any]:
158158
159159
160160@dataclass
161- class Notes (Snippet ):
162- """An abstract :class:`Snippet` subclass ."""
161+ class Code (Snippet ):
162+ """A code block with description ."""
163163 description :List [nodes .Body ]
164-
165- def nodes (self ) -> List [nodes .Node ]:
166- return self .description .copy ()
167-
168-
169- def excerpt (self ) -> str :
170- return self .description [0 ].astext ().replace ('\n ' , '' )
171-
172-
173- def __getstate__ (self ) -> Dict [str ,Any ]:
174- """Implement :py:meth:`pickle.object.__getstate__`."""
175- self .description = [x .deepcopy () for x in self .description ]
176- return super ().__getstate__ ()
177-
178-
179- @dataclass
180- class Code (Notes ):
181- """A piece of :class:`Notes` with code block."""
182164 block :nodes .literal_block
183165
184166 def nodes (self ) -> List [nodes .Node ]:
185- return super (). nodes () + [self .block ]
167+ return self . description . copy () + [self .block ]
186168
187169
188170 def excerpt (self ) -> str :
189- return '/%s/ ' % self .language () + super ().excerpt ()
171+ return '/%s/ ' % self .language () + \
172+ self .description [0 ].astext ().replace ('\n ' , '' )
190173
191174
192175 @classmethod
@@ -198,41 +181,13 @@ def language(self) -> str:
198181 """Return the (programing) language that appears in code."""
199182 return self .block ['language' ]
200183
184+
201185 def __getstate__ (self ) -> Dict [str ,Any ]:
202- """Implement :py:meth:`pickle.object.__getstate__`."""
186+ self . description = [ x . deepcopy () for x in self . description ]
203187 self .block = self .block .deepcopy ()
204188 return super ().__getstate__ ()
205189
206190
207- @dataclass
208- class Procedure (Notes ):
209- """
210- A piece of :class:`Notes` that describes a sequence of :class:`Code`
211- to do something.
212- """
213- steps :List [Code ]
214-
215- def nodes (self ) -> List [nodes .Node ]:
216- nodes_ = []
217- for code in self .steps :
218- nodes_ += code .nodes ()
219- return super ().nodes () + nodes_
220-
221-
222- def excerpt (self ) -> str :
223- return '/%s/ ' % ',' .join (self .languages ()) + super ().excerpt ()
224-
225-
226- @classmethod
227- def kind (cls ) -> str :
228- return 'p'
229-
230-
231- def languages (self ) -> Set [str ]:
232- """Return the (programing) language(s) that appear in procedure."""
233- return set (c .block ['language' ] for c in self .steps )
234-
235-
236191def read_partial_file (filename :str , scope :Tuple [int ,Optional [int ]]) -> List [str ]:
237192 lines = []
238193 with open (filename , "r" ) as f :
@@ -242,7 +197,6 @@ def read_partial_file(filename:str, scope:Tuple[int,Optional[int]]) -> List[str]
242197 lines .append (line .strip ('\n ' ))
243198 return lines
244199
245-
246200def merge_scopes (scopes :List [Tuple [int ,int ]]) -> List [Tuple [int ,int ]]:
247201 """"Merge the overlap scope, the pass-in scopes must be sorted."""
248202 merged = [scopes [0 ]]
0 commit comments