Adds a new section to the current document structure This document structure will be considered a section to the current document structure but will in itself be an entirely new document structure that can be written to and have sections as well :param name:
(self, name, context=None)
| 179 | self.add_new_section(section_name) |
| 180 | |
| 181 | def add_new_section(self, name, context=None): |
| 182 | """Adds a new section to the current document structure |
| 183 | |
| 184 | This document structure will be considered a section to the |
| 185 | current document structure but will in itself be an entirely |
| 186 | new document structure that can be written to and have sections |
| 187 | as well |
| 188 | |
| 189 | :param name: The name of the section. |
| 190 | :param context: A dictionary of data to store with the structure. These |
| 191 | are only stored per section not the entire structure. |
| 192 | :rtype: DocumentStructure |
| 193 | :returns: A new document structure to add to but lives as a section |
| 194 | to the document structure it was instantiated from. |
| 195 | """ |
| 196 | # Add a new section |
| 197 | section = self.__class__( |
| 198 | name=name, target=self.target, context=context |
| 199 | ) |
| 200 | section.path = self.path + [name] |
| 201 | # Indent the section appropriately as well |
| 202 | section.style.indentation = self.style.indentation |
| 203 | section.translation_map = self.translation_map |
| 204 | section.hrefs = self.hrefs |
| 205 | self._structure[name] = section |
| 206 | return section |
| 207 | |
| 208 | def get_section(self, name): |
| 209 | """Retrieve a section""" |
no outgoing calls