@@ -167,8 +167,8 @@ def snake_name(self) -> str:
167167 underscore_name = self .name .replace ('-' , '_' )
168168
169169 no_first_digits_name = '' .join (
170- dropwhile (
171- lambda s : not str .isalpha (s ), underscore_name ))
170+ dropwhile (
171+ lambda s : not str .isalpha (s ), underscore_name ))
172172
173173 return setting_name_replacement .get (
174174 no_first_digits_name ,
@@ -185,12 +185,54 @@ def datatypes_imports(self) -> list[str]:
185185 return datatypes_found
186186
187187
188+ def extract_docbook_paragraphs (docbook_node : Element ) -> List [str ]:
189+ return [x .text for x in docbook_node ]
190+
191+
192+ def extract_description_paragraph (description_node : Element ) -> str :
193+ return description_node .text
194+
195+
188196def extract_and_format_option_description (node : Element ) -> str :
197+ formatted_paragraphs : list [str ] = []
189198 paragraphs : list [str ] = []
190- for para in node .iter ('para' ):
191- paragraphs .append (fill (para .text , width = 72 ))
199+ description = 'Not documented'
200+
201+ for doc_node in node :
202+ if doc_node .tag == 'description-docbook' :
203+ paragraphs .extend (extract_docbook_paragraphs (doc_node ))
204+ elif doc_node .tag == 'description' :
205+ description = extract_description_paragraph (doc_node )
206+ elif doc_node .tag == 'deprecated' :
207+ ...
208+ elif doc_node .tag == 'deprecated-docbook' :
209+ ...
210+ else :
211+ raise ValueError ("Unknown doc node" , doc_node .tag )
212+
213+ if paragraphs :
214+ first_para = paragraphs .pop (0 )
215+ else :
216+ first_para = description
217+
218+ formatted_paragraphs .append (
219+ fill (
220+ first_para ,
221+ width = 72 ,
222+ subsequent_indent = ' ' ,
223+ )
224+ )
225+ for para in paragraphs :
226+ formatted_paragraphs .append (
227+ fill (
228+ para ,
229+ width = 72 ,
230+ initial_indent = ' ' ,
231+ subsequent_indent = ' ' ,
232+ )
233+ )
192234
193- return '\n \n ' .join (paragraphs )
235+ return '\n \n ' .join (formatted_paragraphs )
194236
195237
196238def convert_property (node : Element ,
@@ -253,7 +295,8 @@ class {{ setting.python_class_name }}(NetworkManagerSettingsMixin):
253295{%- endif %}
254296 },
255297 default=None,
256- ){% endfor %}
298+ )
299+ ""\" {{property.description}}""\" {% endfor %}
257300
258301"""
259302
0 commit comments