def _make_index_page(self, elem, level): base = os.path.join(*elem.path) if elem.path else '' res = os.path.join(base, 'index.md') filename = os.path.join(self.docs_dir, res) dirname = os.path.dirname(filename) if dirname: mkdir_p(dirname) kwargs = {} lazy_load_size = self._get_lazy_load_size(elem) if lazy_load_size is not None: kwargs['lazy_load_size'] = lazy_load_size buf = [] with open(filename, 'w') as f: buf.append(self._make_title(elem)) buf.append(self._make_attrs(elem)) buf.append(self._make_nodes(elem, index=True, level=level, **kwargs)) f.write(utf8_encode('\n'.join(buf))) return res
def _make_index_page(self, elem, level): base = os.path.join(*elem.path) if elem.path else '' res = os.path.join(base, 'index.md') filename = os.path.join(self.docs_dir, res) dirname = os.path.dirname(filename) if dirname: mkdir_p(dirname) kwargs = {} lazy_load_size = self._get_lazy_load_size(elem) if lazy_load_size is not None: kwargs['lazy_load_size'] = lazy_load_size buf = [] with open(filename, 'w') as f: buf.append(self._make_title(elem)) buf.append(self._make_attrs(elem)) buf.append( self._make_nodes(elem, index=True, level=level, **kwargs)) f.write(utf8_encode('\n'.join(buf))) return res
def _make_page(self, elem): res = '%s.md' % os.path.join(*elem.path) filename = os.path.join(self.docs_dir, res) dirname = os.path.dirname(filename) if dirname: mkdir_p(dirname) kwargs = {} this_kwargs = {} lazy_load_size = self._get_lazy_load_size(elem) this_lazy_load_size = self._get_this_lazy_load_size(elem) if lazy_load_size is not None: kwargs['lazy_load_size'] = lazy_load_size if this_lazy_load_size is not None: this_kwargs['lazy_load_size'] = this_lazy_load_size buf = [] with open(filename, 'w') as f: buf.append(self._make_title(elem)) buf.append(self._make_attrs(elem, **this_kwargs)) buf.append(self._make_nodes(elem, **kwargs)) f.write(utf8_encode('\n'.join(buf))) return res
def add_line(f, line=None): if line is None: f.write('\n') else: f.write(utf8_encode(line) + '\n')