Skip to content

Commit e9fd9ee

Browse files
init alpha version (#2)
1 parent cbac7aa commit e9fd9ee

28 files changed

Lines changed: 1223 additions & 15 deletions

.editorconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
trim_trailing_whitespace = true
7+
insert_final_newline = true
8+
indent_style = tab
9+
10+
[*.{cmd,bat}]
11+
end_of_line = crlf
12+
13+
[*.{yml,yaml,md}]
14+
indent_style = space
15+
indent_size = 2
16+
17+
[*.py]
18+
indent_style = space
19+
indent_size = 4

.gitattributes

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
###############################
2+
# Git Line Endings #
3+
###############################
4+
5+
# Set default behaviour to automatically normalize line endings.
6+
* text=auto eol=lf
7+
8+
# Force batch scripts to always use CRLF line endings so that if a repo is accessed
9+
# in Windows via a file share from Linux, the scripts will work.
10+
*.{cmd,[cC][mM][dD]} text eol=crlf
11+
*.{bat,[bB][aA][tT]} text eol=crlf
12+
13+
# Force bash scripts to always use LF line endings so that if a repo is accessed
14+
# in Unix via a file share from Windows, the scripts will work.
15+
*.sh text eol=lf
16+
17+
# Common files config
18+
*.jpg -text
19+
*.png -text
20+
*.pdf -text

.github/workflows/workflow.pr.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,23 @@ jobs:
1818
- name: Checkout Repo
1919
uses: actions/checkout@v3
2020

21+
- name: Install Poetry
22+
run: pipx install poetry
23+
2124
- name: Setup Python
2225
uses: actions/setup-python@v4
2326
with:
2427
python-version: "3.10"
2528
cache: "poetry"
2629

27-
- name: Setup Poetry
28-
run: |
29-
pip install poetry
30-
poetry --version
31-
3230
- name: Install dependencies
33-
run: poetry install
31+
run: poetry install --only=dev
3432

3533
- name: Check formatting
3634
run: poetry run black --check .
3735

3836
test:
37+
name: Test
3938
needs: lint
4039
strategy:
4140
fail-fast: false
@@ -47,17 +46,15 @@ jobs:
4746
- name: Checkout Repo
4847
uses: actions/checkout@v3
4948

49+
- name: Install Poetry
50+
run: pipx install poetry
51+
5052
- name: Setup Python
5153
uses: actions/setup-python@v4
5254
with:
5355
python-version: ${{ matrix.python-version }}
5456
cache: "poetry"
5557

56-
- name: Setup Poetry
57-
run: |
58-
pip install poetry
59-
poetry --version
60-
6158
- name: Install dependencies
6259
run: poetry install
6360

.github/workflows/workflow.release.draft.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ jobs:
2020
- name: Release Drafter
2121
uses: release-drafter/release-drafter@v5
2222
id: release-drafter
23-
with:
24-
prerelease: true
2523
env:
2624
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2725

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: Release
3+
4+
on:
5+
release:
6+
types:
7+
- prereleased
8+
- released
9+
- published
10+
11+
jobs:
12+
release:
13+
if: ${{ !github.event.release.prerelease && github.event.action == 'released' && github.repository_owner == 'DariuszPorowski' }}
14+
environment:
15+
name: PyPI
16+
url: "https://pypi.org/project/mkdocs-file-filter-plugin"
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout Repo
20+
uses: actions/checkout@v3
21+
22+
- name: Install Poetry
23+
run: pipx install poetry
24+
25+
- name: Setup Python
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: "3.10"
29+
cache: "poetry"
30+
31+
- name: Install dependencies
32+
run: poetry install
33+
34+
- name: Set Version
35+
run: poetry version ${GITHUB_REF_NAME/v/}
36+
37+
- name: Build
38+
run: poetry build
39+
40+
- name: Publish
41+
run: poetry publish --username=__token__ --password ${{ secrets.PYPI_API_TOKEN }}

.mkdocsignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# MkDocs
2+
docs/test/**
3+
docs/**/draft-*.md

.vscode/settings.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"yaml.schemas": {
3+
"https://squidfunk.github.io/mkdocs-material/schema.json": [
4+
"mkdocs.yml"
5+
]
6+
},
7+
"files.trimTrailingWhitespace": true,
8+
"git.autofetch": true,
9+
"git.fetchOnPull": true,
10+
"git.pruneOnFetch": true,
11+
"git.branchProtection": [
12+
"main",
13+
"master"
14+
],
15+
"files.associations": {
16+
"*.mkdocsignore": "ignore",
17+
".pages": "yaml"
18+
},
19+
"python.linting.enabled": true
20+
}

README.md

Lines changed: 115 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,115 @@
1-
# mkdocs-filesfilter
2-
A mkdocs plugin that lets you exclude/include files or trees from your output.
1+
# File exclude/include plugin for MkDocs
2+
3+
[![PyPI - Version](https://img.shields.io/pypi/v/mkdocs-file-filter-plugin.svg)](https://pypi.org/project/mkdocs-file-filter-plugin)
4+
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mkdocs-file-filter-plugin.svg)](https://pypi.org/project/mkdocs-file-filter-plugin)
5+
6+
---
7+
8+
`mkdocs-file-filter` is a [mkdocs plugin](http://www.mkdocs.org/user-guide/plugins/) that allows you to exclude/include files from your input using Unix-style wildcards (globs), regular expressions (regexes) or .mkdocsignore file ([gitignore-style](https://git-scm.com/docs/gitignore) syntax).
9+
10+
## Quick start
11+
12+
1. Install the plugin using pip.
13+
14+
```console
15+
pip install mkdocs-file-filter-plugin
16+
```
17+
18+
1. In your project, add a plugin configuration to `mkdocs.yml`:
19+
20+
```yaml
21+
plugins:
22+
- file-filter:
23+
mkdocsignore: true
24+
mkdocsignore_file: 'custom/path/.mkdocsignore' # relative to mkdocs.yml
25+
exclude_glob:
26+
- 'exclude/this/path/*'
27+
- 'exclude/this/file/draft.md'
28+
- '*.tmp'
29+
- '*.gz'
30+
exclude_regex:
31+
- '.*\.(tmp|bin|tar)$'
32+
include_glob:
33+
- 'include/this/path/*'
34+
- 'include/this/file/Code-of-Conduct.md'
35+
- '*.png'
36+
- 'assets/**' # the material theme requires this folder
37+
include_regex:
38+
- '.*\.(js|css)$'
39+
```
40+
41+
## External config file
42+
43+
The plugin supports external files for the plugin configuration. If the external config file is specified, then `*_glob:` and `*_regex:` are not taken `mkdocs.yml` - only config from the external file applies.
44+
45+
```yaml
46+
plugins:
47+
- file-filter:
48+
# config: !ENV [MY_FILE_FILTER_CONFIG, 'mkdocs.file-filter.yml']
49+
config: mkdocs.file-filter.yml
50+
```
51+
52+
External plugin config file example.
53+
54+
```yaml
55+
mkdocsignore: false
56+
exclude_glob:
57+
- 'exclude/this/path/*'
58+
- 'exclude/this/file/draft.md'
59+
- '*.tmp'
60+
- '*.gz'
61+
exclude_regex:
62+
- '.*\.(tmp|bin|tar)$'
63+
include_glob:
64+
- 'include/this/path/*'
65+
- 'include/this/file/Code-of-Conduct.md'
66+
- '*.png'
67+
- 'assets/**' # the material theme requires this folder
68+
include_regex:
69+
- '.*\.(js|css)$'
70+
```
71+
72+
> **HINT**
73+
>
74+
> For external file config, you can use [MkDocs Environment Variables](https://www.mkdocs.org/user-guide/configuration/#environment-variables) to set the desired file dynamically. A useful case for serving the site with different content based on stage/environment. Works well with CI/CD automation.
75+
76+
## .mkdocsignore
77+
78+
Setting `mkdocsignore` to `true` will exclude the dirs/files specified in the `.mkdocsignore`. Use the same syntax as you use for gitignore.
79+
80+
Optionally you can set `mkdocsignore_file` parameter with your path to `.mkdocsignore` file. By default, the plugin uses `.mkdocsignore` from the root of your MkDocs.
81+
82+
You can combine mkdocsignore with globs/regex as well. The patterns from both will apply.
83+
84+
External config for mkdocsignore.
85+
86+
```yaml
87+
plugins:
88+
- file-filter:
89+
mkdocsignore: true # default: false
90+
mkdocsignore_file: 'custom/path/.myignore' # relative to mkdocs.yml, default: .mkdocsignore
91+
```
92+
93+
Example `.mkdocsignore` file.
94+
95+
```bash
96+
# MkDocs
97+
docs/test/**
98+
docs/**/draft-*.md
99+
```
100+
101+
## Conflict behavior
102+
103+
It is possible to exclude and include will have conflict. For example, you could exclude `drafts/*` but include `*.md`. In that case, **include** has higher priority over exclude. So all `*.md` files from the drafts folder will be included.
104+
105+
## Some useful stuff
106+
107+
If you do not provide patterns, everything will stay the same - standard MkDocs behavior.
108+
109+
Because of the YAML syntax specifics, patterns that start with a punctuation mark must be quoted.
110+
111+
The preferred way for quotes is to use single quotes `'` rather than double quotes `"` - regex backslash escapes are preserved correctly without being doubled up.
112+
113+
## License
114+
115+
`mkdocs-file-filter-plugin` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.

dev.build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
rm -rf dist && rm -rf build
4+
poetry run black .
5+
poetry build
6+
pip uninstall -y mkdocs_file_filter_plugin
7+
pip install dist/mkdocs_file_filter_plugin-*.tar.gz

docs/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
tags:
3+
- Secrets Store
4+
- Secrets Storage
5+
- Keys Store
6+
- Keys Storage
7+
- Security
8+
---
9+
10+
# file-filter
11+
12+
test

0 commit comments

Comments
 (0)