An MkDocs plugin that reads snippets from Github Repositories.
Project description
mkdocs-git-snippet
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
....
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.
License
Copyright 2021 Mercari, Inc.
Licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mkdocs-git-snippet-0.1.1.tar.gz
.
File metadata
- Download URL: mkdocs-git-snippet-0.1.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51e9c8b014113743f6d9468c43f667f0b81f7bfb8e5ed14c6b4c4c0a2220f17f |
|
MD5 | af80192db00744cef7bab696dc7ad7c1 |
|
BLAKE2b-256 | f4ae30d12ced1bafb563a914b2ddca2f280f8439695f304beea5ac455610e650 |
File details
Details for the file mkdocs_git_snippet-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: mkdocs_git_snippet-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7b579151ec4a6d1a610b9ebf9f736ced3857e7e91eafd7c8b1c18841fdc8bd7 |
|
MD5 | 0384861a006cfe84eabcce03a0a2e6dc |
|
BLAKE2b-256 | 5bf65a265087e804073b4f1de77f98b6e4cb564f919cc3be9d534edcee97e132 |