Skip to main content

Provides the `includex` macro for more flexible includes.

Project description

includex

This is a pluglet for mkdocs-macros. It allows to include arbitrary files in mkdocs (similar to snippets or jinja include) with added convenience.

Installation

pip install mkdocs-macros-includex

Usage

In the config (mkdocs.yml) file:

plugins:
  - search
  - macros:
      modules: ['includex']

Comparison to other tools

snippets (pymdown-extensions)

The main use case this solves over snippets is that it includes partial content (i.e. a section or block) from a file as-is (i.e. without the need for special markers).

Snippets partially supports this now since v9.6 added support to include sections by lines.^snippet-lines Further, v9.7 added to support to sections by name, given that they are marked as such using a special marker comment.^snippet-sections

What includex does additionally is to match the start and end of blocks and include them without the need for any markers or line numbers. While this makes the documentation more prone to break, e.g., when the line that is being matched is changed in a way that it no longer matches, it supports some additional use-cases and requires less custom syntax.

Snippets is implemented as a preprocessor, while includex is implemented as a mkdocs-macros pluglet. This means that snippets are evaluated earlier than includex and prohibits snippets to work with other macros, like this:

{% for file in get_files("docs/") %}
{{ includex(file) }}
{% endfor %}

However, sections included using includex are not evaluated themselves, so includex cannot be nested (yet). If you need nested includes, use snippets instead.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocs_macros_includex-0.0.3.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

mkdocs_macros_includex-0.0.3-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_macros_includex-0.0.3.tar.gz.

File metadata

File hashes

Hashes for mkdocs_macros_includex-0.0.3.tar.gz
Algorithm Hash digest
SHA256 c296158922aa2384785ddcdaa764e5e4a7686a192d61c231ea9faa1295f4548d
MD5 5c8ef86ca8c38ed6733f674647b543ed
BLAKE2b-256 b92937ea0330a0817266bf8bce7dbeff92dac3d311a051f9431aeb93182fce4e

See more details on using hashes here.

File details

Details for the file mkdocs_macros_includex-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_macros_includex-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0f97097b8be2b62bbf095282c789f42d71f79f178a0a620e35e1d83f941498f0
MD5 00d78e63db25aefb73adf4d56dfbd13d
BLAKE2b-256 92063f1870a549e32a48feb5446db9c550917fcf027b4c1522dbe0e11867ec49

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page