File: __init__.py

package info (click to toggle)
abinit 9.10.4-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 518,712 kB
  • sloc: xml: 877,568; f90: 577,240; python: 80,760; perl: 7,019; ansic: 4,585; sh: 1,925; javascript: 601; fortran: 557; cpp: 454; objc: 323; makefile: 77; csh: 42; pascal: 31
file content (48 lines) | stat: -rw-r--r-- 1,785 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# coding: utf-8
from __future__ import print_function, division, unicode_literals, absolute_import

from mkdocs.plugins import BasePlugin


class AbiMkdocsPlugin(BasePlugin):

    #def on_config(self, config, **kwargs):
    #    config['theme'].static_templates.add('my_template.html')
    #    return config

    def on_page_markdown(self, markdown, **kwargs):
        """
        The page_markdown event is called after the page's markdown is loaded from file
        and can be used to alter the Markdown source text.
        The meta-data has been stripped off and is available as page.meta at this point.

        Args:
            markdown: Markdown source text of page as string
            page: mkdocs.nav.Page instance
            config: global configuration object
            site_navigation: global navigation object

        Returns:
            Markdown source text of page as string
        """
        page = kwargs["page"]
        #print("page", page, "\ninput_path", page.input_path, "\npage.meta", page.meta)
        #if "authors" in page.meta:
        #    print("authors:", type(page.meta["authors"]), page.meta["authors"])

        #config = kwargs["config"]
        #for key, value in config["abimkdocs_links"].items():
        #    markdown = markdown.replace(key, value)

        # (Re)Add header with metadata and rpath
        #print(dir(page))
        #print("page.file.src_path:", page.file.src_path)
        #print("page.file.abs_src_path:", page.file.abs_src_path)
        mymeta = page.meta.copy()
        #mymeta["rpath"] = "/" + page.input_path
        mymeta["rpath"] = "/" + page.file.src_path

        header = "---\n" + "\n".join("%s: %s" % item for item in mymeta.items()) + "\n---\n\n"
        #print(header)

        return header + markdown