Automatically insert code snippets to run API calls
Project description
mkdocs-apicall-plugin
Automatically insert code snippets to run API calls
## Simple call
@@@ GET /object/list
## Single header
@@@ GET /object/list
Accept: application/json
## Full call
@@@ POST /data/blob {"a": "b"}
Accept: application/json
Content-Type: application/json
Authorization: Bearer 4P1k3y
Installation
pip install mkdocs-apicall-plugin
This plugin works with the material theme and is built on top of the tabbed
and superfenced
extensions from PyMdown. Enable the extensions and the plugin in your mkdocs.yml
:
theme:
name: material
markdown_extensions:
- pymdownx.superfences
- pymdownx.tabbed:
alternate_style: true
plugins:
- apicall
Syntax
The syntax is given below. Basically it may look like a classical HTTP request message.
@@@ <METHOD> <PATH> [<PAYLOAD>]
[<HEADER-KEY>: <HEADER-VALUE>]
[<HEADER-KEY>: <HEADER-VALUE>]
The method and the paths are both mandatory. One can append a payload (only a json for the moment) to the first line. The following lines are extra indented HTTP headers.
Configuration
The plugin supports few options:
line_length
[int
] is the maximum length of a line of code before splitting into several lines.
icons
[bool
] activates language icons. You must add the following extensions:
markdown_extensions:
# ...
- attr_list
- pymdownx.emoji:
emoji_index: !!python/name:materialx.emoji.twemoji
emoji_generator: !!python/name:materialx.emoji.to_svg
languages
[list
] filters the languages to display (show all by default). The order is also taken into account. The term language is clearly a misuse as it rather refers to a way to make the API call (so we may have curl
, wget
along with typescript
for example). Currently 3 languages are supported: curl
, python
and javascript
.
As an example you may have:
plugins:
- apicall:
line_length: 90
icons: true
languages:
- curl
- python
- javascript
Contributing
Obviously, we need to dev more languages !
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
Hashes for mkdocs-apicall-plugin-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05008d2f9ae0a71361fbcd173056ff322dbd75195dcf340bde86528d9353ba39 |
|
MD5 | b88d0a2e9134a80c8f4ee65875644396 |
|
BLAKE2b-256 | 46ccfcdac0f52ebb4ba832de8ef43cc0ea160ac8813c0dc23f0a5b6b776d5914 |
Hashes for mkdocs_apicall_plugin-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbb7ffa4fcaf2006cf5f6dc84b757acd8afb1f0b45ed4ca92a24ef2e9bd5d745 |
|
MD5 | 1c82f249d94b921714a0c9935a03aaf4 |
|
BLAKE2b-256 | 5521a930aa5e04cd20933250f1605b7c4cb8479490eff5f27a4a88f72728bf56 |