File: __init__.py

package info (click to toggle)
mkdocs-macros-plugin 1.3.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 316 kB
  • sloc: python: 1,216; makefile: 4
file content (32 lines) | stat: -rw-r--r-- 685 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
import os




def define_env(env):
    """
    This is the hook for the functions (new form)
    """

    env.macros.cwd = os.getcwd()

    # use dot notation for adding
    env.macros.baz = env.macros.fix_url('foo')

    # Optional: a special function for making relative urls point to root
    fix_url = env.macros.fix_url

    @env.macro
    def button(label, url):
        "Add a button"
        url = fix_url(url)
        HTML = """<a class='md-button' href="%s">%s</a>"""
        return HTML % (url, label)

    
    env.variables.special_docs_dir = env.variables.config['docs_dir']

    @env.macro
    def show_nav():
        "Show the navigation"
        return env.conf['nav']