-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4799 from himeshsiriwardana/feature-on-off
Added documentation toggle feature
- Loading branch information
Showing
4 changed files
with
93 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"asgardeo_logs": { | ||
"enabled": true, | ||
"page": [ | ||
"guides/asgardeo-logs/index.md", | ||
"guides/asgardeo-logs/diagnostic-logs.md", | ||
"guides/asgardeo-logs/audit-logs.md" | ||
] | ||
}, | ||
|
||
"applications": { | ||
"enabled": true, | ||
"page": [ | ||
"guides/applications/register-single-page-app.md", | ||
"guides/applications/register-oidc-web-app.md", | ||
"guides/applications/register-saml-web-app.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import os | ||
import json | ||
from mkdocs.structure.nav import Section, Page, Link | ||
|
||
def parse_json(file_path): | ||
features_to_remove = {"feature": {}, "page": []} | ||
with open(file_path, 'r') as json_file: | ||
parse_data = json.load(json_file) | ||
for feature, details in parse_data.items(): | ||
enabled = details['enabled'] | ||
page = details['page'] | ||
features_to_remove['feature'][feature] = enabled | ||
|
||
if not enabled: | ||
features_to_remove['page'].extend(page) | ||
json_file.close() | ||
return features_to_remove | ||
|
||
files_to_remove = parse_json(os.path.join(os.getcwd(), 'features.json')) | ||
|
||
def on_files(files, config): | ||
for file in list(files): | ||
if file.src_uri in files_to_remove['page']: | ||
files.remove(file) | ||
return files | ||
|
||
def remove_nav_item(nav_items): | ||
filtered_items = [] | ||
|
||
for item in nav_items: | ||
if isinstance(item, dict): | ||
if any(page in item.values() for page in files_to_remove['page']): | ||
continue | ||
for key, value in item.items(): | ||
if isinstance(value, list): | ||
value = remove_nav_item(value) | ||
item[key] = value | ||
item = {k: v for k, v in item.items() if not (isinstance(v, list) and not v)} | ||
if item: | ||
filtered_items.append(item) | ||
elif isinstance(item, list): | ||
if item: | ||
filtered_items.append(item) | ||
|
||
return filtered_items | ||
|
||
def on_config(config): | ||
|
||
for feature, enabled in files_to_remove['feature'].items(): | ||
config[feature] = enabled | ||
|
||
config['nav'] = remove_nav_item(config['nav']) | ||
return config |
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 |
---|---|---|
@@ -1,15 +1,17 @@ | ||
mkdocs==1.5.3 | ||
mkdocs==1.6.1 | ||
Pygments==2.14.0 | ||
pymdown-extensions==10.3.1 | ||
mkdocs-minify-plugin==0.6.2 | ||
mkdocs-markdownextradata-plugin==0.2.5 | ||
mkdocs-redirects==1.2.0 | ||
pathlib==1.0.1 | ||
mkdocs-material==9.1.2 | ||
markdown==3.2.1 | ||
markdown==3.3.6 | ||
mkdocs-redirects==1.2.0 | ||
mkdocs-exclude==1.0.2 | ||
markdown-include==0.8.1 | ||
jinja2==3.1.2 | ||
mkdocs-glightbox==0.3.4 | ||
mkdocs-include-markdown-plugin==6.0.0 | ||
mkdocs-include-markdown-plugin==6.0.0 | ||
mkdocs-macros-plugin==1.2.0 | ||
mkdocs-exclude==1.0.2 |