-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
Module to assist exclude certain files being processed by plugin. | ||
Inspired by https://github.com/apenwarr/mkdocs-exclude | ||
""" | ||
import os | ||
import fnmatch | ||
from typing import List | ||
|
||
|
||
def exclude(src_path: str, globs: List[str]) -> bool: | ||
""" | ||
Determine if a src_path should be excluded. | ||
Supports globs (e.g. folder/* or *.md). | ||
Credits: code inspired by / adapted from | ||
https://github.com/apenwarr/mkdocs-exclude/blob/master/mkdocs_exclude/plugin.py | ||
Args: | ||
src_path (src): Path of file | ||
globs (list): list of globs | ||
Returns: | ||
(bool): whether src_path should be excluded | ||
""" | ||
assert isinstance(src_path, str) | ||
assert isinstance(globs, list) | ||
|
||
for g in globs: | ||
if fnmatch.fnmatchcase(src_path, g): | ||
return True | ||
|
||
# Windows reports filenames as eg. a\\b\\c instead of a/b/c. | ||
# To make the same globs/regexes match filenames on Windows and | ||
# other OSes, let's try matching against converted filenames. | ||
# On the other hand, Unix actually allows filenames to contain | ||
# literal \\ characters (although it is rare), so we won't | ||
# always convert them. We only convert if os.sep reports | ||
# something unusual. Conversely, some future mkdocs might | ||
# report Windows filenames using / separators regardless of | ||
# os.sep, so we *always* test with / above. | ||
if os.sep != "/": | ||
src_path_fix = src_path.replace(os.sep, "/") | ||
if fnmatch.fnmatchcase(src_path_fix, g): | ||
return True | ||
|
||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
site_name: test gitauthors_plugin | ||
use_directory_urls: true | ||
|
||
plugins: | ||
- search | ||
- git-authors: | ||
exclude: | ||
- page_with_tag.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters