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)
| 157 | self.add_new_section(section_name) |
| 158 | |
| 159 | def add_new_section(self, name, context=None): |
| 160 | """Adds a new section to the current document structure |
| 161 | |
| 162 | This document structure will be considered a section to the |
| 163 | current document structure but will in itself be an entirely |
| 164 | new document structure that can be written to and have sections |
| 165 | as well |
| 166 | |
| 167 | :param name: The name of the section. |
| 168 | :param context: A dictionary of data to store with the strucuture. These |
| 169 | are only stored per section not the entire structure. |
| 170 | :rtype: DocumentStructure |
| 171 | :returns: A new document structure to add to but lives as a section |
| 172 | to the document structure it was instantiated from. |
| 173 | """ |
| 174 | # Add a new section |
| 175 | section = self.__class__( |
| 176 | name=name, target=self.target, context=context |
| 177 | ) |
| 178 | section.path = self.path + [name] |
| 179 | # Indent the section apporpriately as well |
| 180 | section.style.indentation = self.style.indentation |
| 181 | section.translation_map = self.translation_map |
| 182 | section.hrefs = self.hrefs |
| 183 | self._structure[name] = section |
| 184 | return section |
| 185 | |
| 186 | def get_section(self, name): |
| 187 | """Retrieve a section""" |
no outgoing calls
no test coverage detected