-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dynamic generation script for markdown files
- Loading branch information
1 parent
9d728f3
commit f6fa633
Showing
11 changed files
with
109 additions
and
22 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
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,26 @@ | ||
""" | ||
This script dynamically populates the markdown docs for each attack in the `attacks` | ||
directory. Each attack is documented in a separate markdown file with the attack's | ||
name as the filename. The content of each markdown file is dynamically generated | ||
from the docstrings of the attack classes in the `torchattack` module. | ||
Example of the generated docs: | ||
```markdown | ||
# MIFGSM | ||
::: torchattack.MIFGSM | ||
``` | ||
""" | ||
|
||
import os | ||
|
||
import mkdocs_gen_files | ||
|
||
import torchattack as ta | ||
|
||
for attack_name in ta.SUPPORTED_ATTACKS: | ||
filename = os.path.join('attacks', f'{attack_name.lower()}.md') | ||
with mkdocs_gen_files.open(filename, 'w') as f: | ||
f.write(f'# {attack_name}\n\n::: torchattack.{attack_name}\n') | ||
mkdocs_gen_files.set_edit_path(filename, 'docs/populate_attack_apis.py') |
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,27 @@ | ||
:root > * { | ||
--md-primary-fg-color: #2066d6; | ||
--md-accent-fg-color: #df332a; | ||
--md-typeset-a-color: #2066d6; | ||
} | ||
|
||
[data-md-color-scheme="slate"] { | ||
--md-default-bg-color: hsl(240, 12%, 14%); | ||
--md-primary-fg-color: #3394e4 !important; | ||
--md-accent-fg-color: #df332a !important; | ||
--md-typeset-a-color: #3394e4 !important; | ||
} | ||
|
||
.md-header, | ||
.md-tabs { | ||
color: inherit !important; | ||
background-color: var(--md-default-bg-color); | ||
} | ||
[data-md-color-scheme="slate"] .md-header, | ||
[data-md-color-scheme="slate"] .md-tabs { | ||
background-color: var(--md-default-bg-color); | ||
} | ||
@media screen and (min-width: 76.25em) { | ||
[data-md-color-scheme="slate"] .md-tabs { | ||
border-bottom: 0.05rem solid rgba(255, 255, 255, 0.07); | ||
} | ||
} |
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