mirror of
https://github.com/nlohmann/json.git
synced 2024-11-23 22:19:02 +08:00
Exclude internal pages from style check
This commit is contained in:
parent
74d2ec12e9
commit
60ea4e8f8b
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import glob
|
||||
import os.path
|
||||
@ -8,6 +8,28 @@ import sys
|
||||
warnings = 0
|
||||
|
||||
|
||||
def filter_internal(files):
|
||||
try:
|
||||
import mkdocs.utils.meta
|
||||
except ModuleNotFoundError:
|
||||
print('Module mkdocs.utils.meta not found. Cannot exclude internal documentation pages from checks.')
|
||||
return files
|
||||
|
||||
internal_paths = []
|
||||
for file in files:
|
||||
_, data = mkdocs.utils.meta.get_data(file)
|
||||
if data.get('x-nlohmann-json-is-internal', False):
|
||||
internal_paths.append(os.path.dirname(file))
|
||||
|
||||
def parent_of(path, parent):
|
||||
return os.path.commonpath([parent]) == os.path.commonpath([path, parent])
|
||||
|
||||
return [
|
||||
file for file in files
|
||||
if not any(parent_of(file, path) for path in internal_paths)
|
||||
]
|
||||
|
||||
|
||||
def report(rule, location, description):
|
||||
global warnings
|
||||
warnings += 1
|
||||
@ -45,7 +67,7 @@ def check_structure():
|
||||
'Version history'
|
||||
]
|
||||
|
||||
files = sorted(glob.glob('api/**/*.md', recursive=True))
|
||||
files = sorted(filter_internal(glob.glob('api/**/*.md', recursive=True)))
|
||||
for file in files:
|
||||
with open(file) as file_content:
|
||||
section_idx = -1 # the index of the current h2 section
|
||||
|
Loading…
Reference in New Issue
Block a user