Exemplo n.º 1
0
def main():

    with open('sitemap.yaml') as f:
        d = orderedLoad(f)
    with open('themes/cogsci/templates/mega-menu-content.html', 'w') as f:
        f.write(build_menu(d))
    print('Generated menu content')
    sitemap = build_live_sitemap(d)
    with open(u'static/sitemap.yml', u'w') as fd:
        yaml.dump(sitemap, fd, default_flow_style=False)
    print('Generated live sitemap')
Exemplo n.º 2
0
    def _dict(self):
        """
		desc:
			Generates a dict representation of the object's documentation.

		returns:
			desc:	A dict representation of the object's documentation.
			type:	dict
		"""

        docStr = inspect.getdoc(self.obj)
        if docStr is None:
            _dict = OrderedDict([(u'visible', False)])
        elif isinstance(docStr, basestring):
            docStr = safe_decode(docStr, self.enc)
            # If the docstring contains a YAML block between '---' then we
            # use only this bit.
            for r in re.finditer(u'^---(.*?)^---', docStr, re.M | re.S):
                docStr = r.groups()[0]
                break
            try:
                _dict = orderedLoad(docStr)
                if isinstance(_dict, basestring):
                    _dict = OrderedDict([(u'desc',
                                          safe_decode(_dict, self.enc)),
                                         (u'visible', False)])
                elif _dict is None:
                    _dict = OrderedDict([(u'visible', False)])
            except:
                # If the docstring appears to be YAML formatted, but
                # nevertheless fails to parse, we raise an exception to inform
                # the user of the problem.
                if docStr.strip().startswith(u'desc:'):
                    orderedLoad(docStr)  # Will raise Exception
                _dict = OrderedDict([(u'desc', docStr), (u'visible', False)])
        if u'desc' not in _dict:
            _dict[u'desc'] = self.undefined
        if u'visible' not in _dict:
            _dict[u'visible'] = True
        _dict = self.stripDict(_dict)
        return _dict
Exemplo n.º 3
0
def init_academicmarkdown(sender):

    build.postMarkdownFilters = []
    build.figureTemplate = 'jekyll'
    build.tableTemplate = 'kramdown'
    build.figureSourcePrefix = SITEURL
    build.path += u'include'
    build.extensions.remove('toc')
    build.extensions.insert(0, 'toc')
    with open('sitemap.yaml') as f:
        d = orderedLoad(f)
    process_links(d)