diff --git a/docs/requirements-docs.txt b/docs/requirements-docs.txt index cbf1e3658..4a5fb0dee 100644 --- a/docs/requirements-docs.txt +++ b/docs/requirements-docs.txt @@ -1,2 +1,3 @@ sphinx sphinx-rtd-theme +pydata-sphinx-theme diff --git a/docs/source/_ext/garak_ext.py b/docs/source/_ext/garak_ext.py index f63b6a9d0..959cd757b 100644 --- a/docs/source/_ext/garak_ext.py +++ b/docs/source/_ext/garak_ext.py @@ -25,7 +25,8 @@ def run(self) -> list: probe_ref = f":obj:`~garak.probes.{probe}`" detector_ref = f":obj:`~garak.detectors.{detector}`" - rst += f"\n* {probe_ref}: {100*(1-scores["mu"]):.1f}% with detector {detector_ref}" + mu = 1 - scores["mu"] + rst += f"\n* {probe_ref}: {100*(mu):.1f}% with detector {detector_ref}" if rst: rst = ( diff --git a/docs/source/_static/css/custom.css b/docs/source/_static/css/custom.css new file mode 100644 index 000000000..f8f7af9cb --- /dev/null +++ b/docs/source/_static/css/custom.css @@ -0,0 +1,40 @@ +.reference, +.icon-home, +a:link, +a:visited, +a:hover, +a:active { + color: #76b900; /* nv */ +} + +.wy-menu-vertical li.toctree-l1.current>a, +li.toctree-l1.current>a:link, +li.toctree-l2.current>a:link, +.wy-menu-vertical li.toctree-l3.current>a>code, +.rst-content code.literal { + color: #76b900; +} + +.btn-neutral:link, +.btn-neutral:visited, +.btn-neutral:hover, +.btn-neutral:active { + color: #76b900 !important; +} + +html[data-theme=light], html[data-theme=dark]{ +--pst-color-primary: #76b900; +--pst-color-secondary: #76b900; /* nv */ +--pst-color-inline-code: #76b900; +--pst-color-inline-code-links: #76b900; +} + +html[data-theme=light]{ +--pst-color-info-bg: #E0E0E0; +--pst-color-info: #000000; +} + +html[data-theme=dark]{ +--pst-color-info-bg: #000000; +--pst-color-info: #E0E0E0; +} \ No newline at end of file diff --git a/docs/source/_static/switcher.json b/docs/source/_static/switcher.json new file mode 100644 index 000000000..7c6fcac58 --- /dev/null +++ b/docs/source/_static/switcher.json @@ -0,0 +1,12 @@ + + { + "name": "latest", + "version": "latest", + "url": "https://reference.garak.ai/en/latest/" + }, + { + "name": "stable", + "version": "stable", + "url": "https://reference.garak.ai/en/stable/" + } +] \ No newline at end of file diff --git a/docs/source/conf.py b/docs/source/conf.py index fe3563669..3e9a4f006 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -6,6 +6,7 @@ project = "garak" copyright = f"2023-{datetime.datetime.now().year}, NVIDIA Corporation" author = "Leon Derczynski" +version: str = 'latest' # required by the version switcher # -- General configuration @@ -16,6 +17,7 @@ "sphinx.ext.autosummary", "sphinx.ext.intersphinx", "sphinx.ext.napoleon", + "sphinx.ext.viewcode", "garak_ext" ] @@ -23,14 +25,27 @@ "python": ("https://docs.python.org/3/", None), "sphinx": ("https://www.sphinx-doc.org/en/master/", None), } + intersphinx_disabled_domains = ["std"] templates_path = ["_templates"] -exclude_patterns = [] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"] # -- Options for HTML output -html_theme = "sphinx_rtd_theme" +html_theme = "pydata_sphinx_theme" + +html_theme_options = { + "navbar_start": ["navbar-logo", "version-switcher"], + "switcher": { + "json_url": "https://raw.githubusercontent.com/NVIDIA/garak/refs/heads/main/docs/source/_static/switcher.json", + "version_match": version + }, +} + +html_sidebars = { + "**": ["sidebar-nav-bs"], +} # These folders are copied to the documentation's HTML output html_static_path = ['_static'] @@ -38,7 +53,7 @@ # These paths are either relative to html_static_path # or fully qualified paths (eg. https://...) html_css_files = [ - "css/garak_theme.css", + "css/custom.css", ] # -- Options for EPUB output @@ -48,4 +63,4 @@ import sys sys.path.insert(0, "../..") -sys.path.append(os.path.abspath("./_ext")) \ No newline at end of file +sys.path.append(os.path.abspath("./_ext")) diff --git a/docs/source/extending_and_contributing.rst b/docs/source/extending_and_contributing.rst new file mode 100644 index 000000000..d57bcb481 --- /dev/null +++ b/docs/source/extending_and_contributing.rst @@ -0,0 +1,10 @@ +Extending and Contributing +========================== + +.. toctree:: + :maxdepth: 1 + + extending + extending.generator + extending.probe + contributing \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index d973ddc96..a70fa1d6c 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -28,50 +28,9 @@ Check out the :doc:`usage` section for further information, including :doc:`inst .. toctree:: - :caption: Using garak :maxdepth: 1 - :hidden: - how - install - usage - configurable - cliref - reporting - translation - ascii_smuggling - FAQ + using_garak + reference + extending_and_contributing -.. toctree:: - :caption: Reference - :maxdepth: 1 - :hidden: - - basic - attempt - buffs - cli - command - detectors - evaluators - exception - generators - harnesses - interactive - langservice - payloads - probes - report - _config - _plugins - - -.. toctree:: - :caption: Extending and Contributing - :maxdepth: 1 - :hidden: - - extending - extending.generator - extending.probe - contributing diff --git a/docs/source/reference.rst b/docs/source/reference.rst new file mode 100644 index 000000000..e1a9e693a --- /dev/null +++ b/docs/source/reference.rst @@ -0,0 +1,23 @@ +Reference +========= + +.. toctree:: + :maxdepth: 1 + + basic + attempt + buffs + cli + command + detectors + evaluators + exception + generators + harnesses + interactive + langservice + payloads + probes + report + _config + _plugins \ No newline at end of file diff --git a/docs/source/using_garak.rst b/docs/source/using_garak.rst new file mode 100644 index 000000000..4555c05da --- /dev/null +++ b/docs/source/using_garak.rst @@ -0,0 +1,15 @@ +Using ``garak`` +================ + +.. toctree:: + :maxdepth: 1 + + how + install + usage + configurable + cliref + reporting + translation + ascii_smuggling + FAQ