Skip to content

Commit

Permalink
Update vscode debugging files, add support for tags and datatables (#…
Browse files Browse the repository at this point in the history
…2653)

* add support for tags

* add tasks and launch for debugging

* remove launch.json from .gitignore

* Add DataTables plugin for table functionality replacing tablesort
  • Loading branch information
cpholguera authored Jul 7, 2024
1 parent f665157 commit 1efab90
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 3 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ logs
*.pdf
*.docx
*.epub
launch.json
docs/MASVS/**/
docs/MASVS/*-MASVS-*.md
docs/MASTG/**/
Expand Down
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true
},
{
"name": "Python: MkDocs Serve",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/.venv/bin/mkdocs", // Adjust the path if mkdocs is not in a virtual environment
"args": ["serve", "-a", "localhost:8002"],
"console": "integratedTerminal",
"env": {
"PYTHONPATH": "${workspaceFolder}/.venv/bin/python3"
},
"preLaunchTask": "Run populate_dynamic_pages.py"
}
]
}
27 changes: 27 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Run structure_mastg.sh",
"type": "shell",
"command": "./src/scripts/structure_mastg.sh",
"problemMatcher": []
},
{
"label": "Run transform_files.py",
"type": "shell",
"command": "${workspaceFolder}/.venv/bin/python",
"args": ["src/scripts/transform_files.py"],
"problemMatcher": [],
"dependsOn": "Run structure_mastg.sh"
},
{
"label": "Run populate_dynamic_pages.py",
"type": "shell",
"command": "${workspaceFolder}/.venv/bin/python",
"args": ["src/scripts/populate_dynamic_pages.py"],
"problemMatcher": [],
"dependsOn": "Run transform_files.py"
}
]
}
28 changes: 28 additions & 0 deletions docs/hooks/add-tags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import logging
import mkdocs.plugins

log = logging.getLogger('mkdocs')

# https://www.mkdocs.org/dev-guide/plugins/#on_page_markdown
@mkdocs.plugins.event_priority(-50)
def on_page_markdown(markdown, page, **kwargs):
path = page.file.src_uri

if "MASWE/" in path:

tags = page.meta.get('tags', [])

if page.meta.get('platform'):
for platform in page.meta.get('platform', []):
tags.append(platform)
if page.meta.get('profiles'):
for profile in page.meta.get('profiles', []):
tags.append(profile)

if page.meta.get('masvs-v2'):
for masvs_v2 in page.meta.get('masvs-v2', []):
tags.append(masvs_v2)

page.meta['tags'] = tags

return markdown
5 changes: 5 additions & 0 deletions docs/javascripts/datatables.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
document$.subscribe(function() {
$('table').DataTable({
paging: false
});
});
3 changes: 3 additions & 0 deletions docs/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Tags

<!-- material/tags -->
23 changes: 21 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ theme:
favicon: assets/logo_circle.png
icon:
repo: fontawesome/brands/github
tag:
android: material/android
ios: material/apple
p: material/eye-circle-outline
l1: material/circle
l2: material/circle-multiple-outline
r: material/circle-double
features:
- search.suggest
- search.share
Expand All @@ -167,15 +174,19 @@ theme:

extra_css:
- stylesheets/extra.css
- https://cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css
extra_javascript:
- javascripts/tablesort.min.js
- javascripts/tablesorts.js
- javascripts/external_links.js
- https://code.jquery.com/jquery-3.5.1.js
- https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js
- javascripts/datatables.js
plugins:
# Uses https://github.com/mkdocs/mkdocs-redirects getting the redirects map from src/scripts/generate_redirects.py
- search
- awesome-pages
- mermaid2
- tags
# tags_file: tags.md # TODO: bug in mkdocs? dynamic tags from hooks not appearing in tags.md
markdown_extensions:
- meta
- toc:
Expand Down Expand Up @@ -210,6 +221,7 @@ hooks:
- docs/hooks/replace_snippets.py
- docs/hooks/update_titles.py
- docs/hooks/maswe-beta-banner.py
- docs/hooks/add-tags.py

extra:
generator: false # removed but recreated in copyright above
Expand All @@ -229,3 +241,10 @@ extra:
# - icon: fontawesome/solid/paper-plane
# link: mailto:[email protected]
# name: Sven Schleier
tags:
android: android
ios: ios
P: p
L1: l1
L2: l2
R: r

0 comments on commit 1efab90

Please sign in to comment.