fralau / mkdocs-macros-plugin

Create richer and more beautiful pages in MkDocs, by using variables and calls to macros in the markdown code.
https://mkdocs-macros-plugin.readthedocs.io
Other
321 stars 50 forks source link

Document directory tree for macros #130

Closed fralau closed 2 years ago

fralau commented 2 years ago

@fuchsst how I managed to do it is as follows: (@fralau pls correct me if there is a smoother way)

macros
├── __init__.py
├── utils.py
├── model.py
└── logic.py

in init.py is the only def define_env(env) function across the repo. Within the @env.macros function you call functions that you import from other py files:

from .model import list_of_tables,meta_header,data_header
from .logic import create_zip_file
from .model import create_md_table

def define_env(env):
    @env.macro
    def download_as_xlsx():
        s = create_zip_file()
        return s

    @env.macro
    def create_tables():
        s = create_md_table(list_of_tables,meta_header,data_header,'pipe')
        return s

    ....

_Originally posted by @lennizle in https://github.com/fralau/mkdocs_macros_plugin/discussions/120#discussioncomment-2131444_

fralau commented 2 years ago

Upate documentation with that info, to give a model.

fralau commented 2 years ago

This is now documented in the macros page.