Skip to main content

An MkDocs plugin that reads snippets from Github Repositories.

Project description

mkdocs-git-snippet Test Code style: black

Mkdocs Plugin for snippet from git repository.

Installation

pip install mkdocs-git-snippet

Configuration

Enable the plugin in your mkdocs.yml.

plugins:
  - git-snippet

If the folder name that contain your documentation source files is not default docs, you need specify it with base_path option.

plugins:
  - git-snippet:
        base_path: docs

By default, this plugin works for all pages. You can enable only for the specific page by setting all_pages option to false.

plugins:
  - git-snippet:
      all_pages: false

When all_pages is false, this plugin only works for the page that added git-snippet: enable.

<!-- git-snippet: enable -->

# Your document
....

Acessing Private Repositories

To add a snippet from a private repository set the GITHUB_TOKEN environment variable while building mkdocs documentation.

Usage

All files from default branch

{{ gitsnippet('mkdocs/mkdocs', 'docs/user-guide/plugins.md') }}

It works for non markdown file too. The snippet format is raw text. Please format it if needed.

```python
{{ gitsnippet('mkdocs/mkdocs', 'mkdocs/config/base.py') }}
```

All files from specific branch/tag/commit

```python
{ gitsnippet('mkdocs/mkdocs', 'mkdocs/config/base.py', '1.1')
```
```python
{{ gitsnippet('mkdocs/mkdocs', 'mkdocs/config/base.py', '520314fed933aed8de62b08dd7fc6e25c0ff482b') }}
```

Snippet a section

For markdown file, it is possible to specify a section.

{{ gitsnippet('mkdocs/mkdocs', 'docs/user-guide/plugins.md', section='## Using Plugins') }}

or

{{ gitsnippet('mkdocs/mkdocs', 'docs/user-guide/plugins.md', 'master', '## Using Plugins') }}

Insert indent

You can insert indent to snippet using indent. indent has an argument width, which means the number of space to indent by. The default is 4. See more details of indent here.

??? example "Plugin.md"

    {{ gitsnippet('mkdocs/mkdocs', 'docs/user-guide/plugins.md') | indent }}

    !!! note

        ```python
        {{ gitsnippet('mkdocs/mkdocs', 'mkdocs/config/base.py) | indent(width=8) }}
        ```

Contribution

Please read the CLA carefully before submitting your contribution to Mercari. Under any circumstances, by submitting your contribution, you are deemed to accept and agree to be bound by the terms and conditions of the CLA.

https://www.mercari.com/cla/

License

Copyright 2021 Mercari, Inc.

Licensed under the MIT License.

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-git-snippet-0.1.2.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

mkdocs_git_snippet-0.1.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs-git-snippet-0.1.2.tar.gz.

File metadata

  • Download URL: mkdocs-git-snippet-0.1.2.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for mkdocs-git-snippet-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2c358e402cd74e86fe966a3199b23572a7f7349da0dd72f3cffdf946b59ba974
MD5 4aefeb1443e4f1de9eec6e0e2877ec7d
BLAKE2b-256 b800763b952253f1a45305f1d23b189d77dbda2616c304c2bbb83628dd0c1c72

See more details on using hashes here.

File details

Details for the file mkdocs_git_snippet-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_git_snippet-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9c579180e2b1128499cf7245074f62f69ecdccf1ecb806bcb11ea862ee3b994a
MD5 1502ef08af9872e1705ce0b4e8c35283
BLAKE2b-256 fd3708259add87835b6cd07b9b117f3c06e7c09e64944f8e459bd9d513eba9ff

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