Skip to content

Commit

Permalink
Merge pull request #4799 from himeshsiriwardana/feature-on-off
Browse files Browse the repository at this point in the history
Added documentation toggle feature
  • Loading branch information
himeshsiriwardana authored Nov 7, 2024
2 parents d932b18 + a599c6f commit 755ee85
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 3 deletions.
19 changes: 19 additions & 0 deletions en/asgardeo/features.json
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"
]
}
}
53 changes: 53 additions & 0 deletions en/asgardeo/hooks.py
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
16 changes: 16 additions & 0 deletions en/asgardeo/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ watch:
- ../theme/material
- ../base.yml

hooks:
- hooks.py

plugins:
- search
- markdownextradata: {}
Expand Down Expand Up @@ -125,12 +128,25 @@ plugins:
'apis/oauth-dcr.md' : 'apis/dynamic-client-registration-rest-api.md'
'/guides/authorization/impersonation/user-impersonation/' : '/guides/authorization/user-impersonation/'

exclude_docs: |
/get-started/hello-world.md
not_in_nav: |
/page-not-found.md
/get-started/explore-asgardeo.md
/get-started/start-integrating-apps.md
/get-started/try-samples/index.md
/get-started/try-your-own-app/index.md
/get-started/try-your-own-app/angular.md
/get-started/hello-world.md
# Navigation
nav:
- Home:
- Home: index.md
- Get Started:
- Get Started - Overview: get-started/index.md
- Hello world: get-started/hello-world.md
- Create your Asgardeo account: get-started/create-asgardeo-account.md
- Try login with Asgardeo: get-started/try-it-application.md
- Start integrating Asgardeo into apps:
Expand Down
8 changes: 5 additions & 3 deletions en/asgardeo/requirements.txt
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

0 comments on commit 755ee85

Please sign in to comment.