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.2.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

mkdocs_macros_includex-0.0.2-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for mkdocs_macros_includex-0.0.2.tar.gz
Algorithm Hash digest
SHA256 cb61349bd8b39f65b62eccc90ff7d2a51aac5e57002583afc73197282e62290d
MD5 2006a853890dfd529d78eb6c94c1a78e
BLAKE2b-256 431b161a654ff0b92fcd39e777b0ba62d37112c77a842bb779953f7c0f167026

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mkdocs_macros_includex-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1dda0c53e891a2bfebf8322d44573dae04ed7bd071d035e4a7b259d9dfb9fbbf
MD5 870af97fd9fc3cd75e37d4976c3e2d1a
BLAKE2b-256 d16394c61925f205fde182140d8c8b4b3555861336f6a46833d8023a58315676

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