Skip to content

Commit 651760f

Browse files
committed
Initial add
0 parents  commit 651760f

File tree

8 files changed

+312
-0
lines changed

8 files changed

+312
-0
lines changed

.gitignore

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
*~
2+
3+
# Byte-compiled / optimized / DLL files
4+
__pycache__/
5+
*.py[cod]
6+
*$py.class
7+
8+
# C extensions
9+
*.so
10+
11+
# Distribution / packaging
12+
.Python
13+
build/
14+
develop-eggs/
15+
dist/
16+
downloads/
17+
eggs/
18+
.eggs/
19+
lib/
20+
lib64/
21+
parts/
22+
sdist/
23+
var/
24+
wheels/
25+
share/python-wheels/
26+
*.egg-info/
27+
.installed.cfg
28+
*.egg
29+
MANIFEST
30+
31+
# PyInstaller
32+
# Usually these files are written by a python script from a template
33+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
34+
*.manifest
35+
*.spec
36+
37+
# Installer logs
38+
pip-log.txt
39+
pip-delete-this-directory.txt
40+
41+
# Unit test / coverage reports
42+
htmlcov/
43+
.tox/
44+
.nox/
45+
.coverage
46+
.coverage.*
47+
.cache
48+
nosetests.xml
49+
coverage.xml
50+
*.cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
63+
# Flask stuff:
64+
instance/
65+
.webassets-cache
66+
67+
# Scrapy stuff:
68+
.scrapy
69+
70+
# Sphinx documentation
71+
docs/_build/
72+
73+
# PyBuilder
74+
target/
75+
76+
# Jupyter Notebook
77+
.ipynb_checkpoints
78+
79+
# IPython
80+
profile_default/
81+
ipython_config.py
82+
83+
# pyenv
84+
.python-version
85+
86+
# celery beat schedule file
87+
celerybeat-schedule
88+
89+
# SageMath parsed files
90+
*.sage.py
91+
92+
# Environments
93+
.env
94+
.venv
95+
env/
96+
venv/
97+
ENV/
98+
env.bak/
99+
venv.bak/
100+
101+
# Spyder project settings
102+
.spyderproject
103+
.spyproject
104+
105+
# Rope project settings
106+
.ropeproject
107+
108+
# mkdocs documentation
109+
/site
110+
111+
# mypy
112+
.mypy_cache/
113+
.dmypy.json
114+
dmypy.json
115+
116+
# Pyre type checker
117+
.pyre/

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2018 Your Name Here
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# mkdocs-bootstrap-tables-plugin
2+
3+
This plugin converts the raw `<table>` elements that result from basic markdown, and augments them with [Bootstrap table classes](https://getbootstrap.com/docs/4.0/content/tables/) for improved styling.
4+
5+
## Setup
6+
7+
Install the plugin using pip:
8+
9+
`pip install mkdocs-bootstrap-tables-plugin`
10+
11+
Activate the plugin in `mkdocs.yml`:
12+
```yaml
13+
plugins:
14+
- search
15+
- bootstrap-tables
16+
```
17+
18+
> **Note:** If you have no `plugins` entry in your config file yet, you'll likely also want to add the `search` plugin. MkDocs enables it by default if there is no `plugins` entry set, but now you have to enable it explicitly.
19+
20+
More information about plugins in the [MkDocs documentation][mkdocs-plugins].
21+
22+
## Usage
23+
24+
Enabling this plugin will take a simple table generated by markdown:
25+
26+
### Original Markdown
27+
28+
```
29+
| Parameter | Type | Description |
30+
| --------------- | ------ | ----------- |
31+
| `foo` | string | A parameter that does something. |
32+
| `bar` | int | A parameter that does something. |
33+
| `baz` | URI | Required. You better use this. |
34+
```
35+
36+
### HTML before processing
37+
38+
This is the HTML that Markdown will produce:
39+
40+
```html
41+
<table>
42+
<thead>
43+
<tr>
44+
<th>Parameter</th>
45+
<th>Type</th>
46+
<th>Description</th>
47+
</tr>
48+
</thead>
49+
<tbody>
50+
<tr>
51+
<td><code>foo</code></td>
52+
<td>string</td>
53+
<td></td>
54+
</tr>
55+
<tr>
56+
<td><code></code></td>
57+
<td>int</td>
58+
<td>A parameter that does something.</td>
59+
</tr>
60+
<tr>
61+
<td><code>baz</code></td>
62+
<td>A parameter that does something.URI</td>
63+
<td>Required. You better use this.</td>
64+
</tr>
65+
</tbody>
66+
</table>
67+
```
68+
69+
### HTML after processing
70+
71+
This is the HTML after this plugin has run:
72+
73+
```html
74+
<table class="table">
75+
<thead>
76+
<tr>
77+
<th scope="col">Parameter</th>
78+
<th scope="col">Type</th>
79+
<th scope="col">Description</th>
80+
</tr>
81+
</thead>
82+
<tbody>
83+
<tr>
84+
<td><code>foo</code></td>
85+
<td>string</td>
86+
<td></td>
87+
</tr>
88+
<tr>
89+
<td><code></code></td>
90+
<td>int</td>
91+
<td>A parameter that does something.</td>
92+
</tr>
93+
<tr>
94+
<td><code>baz</code></td>
95+
<td>A parameter that does something.URI</td>
96+
<td>Required. You better use this.</td>
97+
</tr>
98+
</tbody>
99+
</table>
100+
```
101+
102+
## See Also
103+
104+
More information about templates [here][mkdocs-template].
105+
106+
More information about blocks [here][mkdocs-block].
107+
108+
[mkdocs-plugins]: http://www.mkdocs.org/user-guide/plugins/
109+
[mkdocs-template]: https://www.mkdocs.org/user-guide/custom-themes/#template-variables
110+
[mkdocs-block]: https://www.mkdocs.org/user-guide/styling-your-docs/#overriding-template-blocks

deploy.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
rm -rf dist
4+
python setup.py bdist_wheel sdist --formats gztar && twine upload dist/*

mkdocs_bootstrap_tables_plugin/__init__.py

Whitespace-only changes.
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import os
2+
import sys
3+
import re
4+
from timeit import default_timer as timer
5+
from datetime import datetime, timedelta
6+
7+
from mkdocs import utils as mkdocs_utils
8+
from mkdocs.config import config_options, Config
9+
from mkdocs.plugins import BasePlugin
10+
11+
class BootstrapTablesPlugin(BasePlugin):
12+
13+
config_scheme = (
14+
('param', config_options.Type(mkdocs_utils.string_types, default='')),
15+
)
16+
17+
def __init__(self):
18+
self.enabled = True
19+
self.total_time = 0
20+
21+
def on_post_page(self, output_content, page, config):
22+
output_content = re.sub(r"<table>", "<table class=\"table\">", output_content)
23+
output_content = re.sub(r"<th>", "<th scope=\"col\">", output_content)
24+
return output_content
25+

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mkdocs==1.0.3

setup.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from setuptools import setup, find_packages
2+
3+
4+
setup(
5+
name='mkdocs-bootstrap-tables-plugin',
6+
version='0.1.0',
7+
description='A MkDocs plugin to add bootstrap classes to plan markdown generated tables.',
8+
long_description='',
9+
keywords='mkdocs bootstrap css',
10+
url='https://github.com/byrnereese/mkdocs-bootstrap-tables-plugin',
11+
author='Byrne Reese',
12+
author_email='[email protected]',
13+
license='MIT',
14+
python_requires='>=2.7',
15+
install_requires=[
16+
'mkdocs>=1.0.4'
17+
],
18+
classifiers=[
19+
'Development Status :: 4 - Beta',
20+
'Intended Audience :: Developers',
21+
'Intended Audience :: Information Technology',
22+
'License :: OSI Approved :: MIT License',
23+
'Programming Language :: Python',
24+
'Programming Language :: Python :: 3 :: Only',
25+
'Programming Language :: Python :: 3.4',
26+
'Programming Language :: Python :: 3.5',
27+
'Programming Language :: Python :: 3.6',
28+
'Programming Language :: Python :: 3.7'
29+
],
30+
packages=find_packages(),
31+
entry_points={
32+
'mkdocs.plugins': [
33+
'bootstrap-tables = mkdocs_bootstrap_tables_plugin.plugin:BootstrapTablesPlugin'
34+
]
35+
}
36+
)

0 commit comments

Comments
 (0)