| 104 | |
| 105 | |
| 106 | class DocumentStructure(ReSTDocument): |
| 107 | def __init__(self, name, section_names=None, target='man', context=None): |
| 108 | """Provides a Hierarichial structure to a ReSTDocument |
| 109 | |
| 110 | You can write to it similiar to as you can to a ReSTDocument but |
| 111 | has an innate structure for more orginaztion and abstraction. |
| 112 | |
| 113 | :param name: The name of the document |
| 114 | :param section_names: A list of sections to be included |
| 115 | in the document. |
| 116 | :param target: The target documentation of the Document structure |
| 117 | :param context: A dictionary of data to store with the strucuture. These |
| 118 | are only stored per section not the entire structure. |
| 119 | """ |
| 120 | super().__init__(target=target) |
| 121 | self._name = name |
| 122 | self._structure = OrderedDict() |
| 123 | self._path = [self._name] |
| 124 | self._context = {} |
| 125 | if context is not None: |
| 126 | self._context = context |
| 127 | if section_names is not None: |
| 128 | self._generate_structure(section_names) |
| 129 | |
| 130 | @property |
| 131 | def name(self): |
| 132 | """The name of the document structure""" |
| 133 | return self._name |
| 134 | |
| 135 | @property |
| 136 | def path(self): |
| 137 | """ |
| 138 | A list of where to find a particular document structure in the |
| 139 | overlying document structure. |
| 140 | """ |
| 141 | return self._path |
| 142 | |
| 143 | @path.setter |
| 144 | def path(self, value): |
| 145 | self._path = value |
| 146 | |
| 147 | @property |
| 148 | def available_sections(self): |
| 149 | return list(self._structure) |
| 150 | |
| 151 | @property |
| 152 | def context(self): |
| 153 | return self._context |
| 154 | |
| 155 | def _generate_structure(self, section_names): |
| 156 | for section_name in section_names: |
| 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 |
no outgoing calls
no test coverage detected