diff --git a/doc/changelog.d/642.added.md b/doc/changelog.d/642.added.md new file mode 100644 index 000000000..a9d06a30c --- /dev/null +++ b/doc/changelog.d/642.added.md @@ -0,0 +1 @@ +feat: Add Tox environment for documentation preview \ No newline at end of file diff --git a/doc/source/conf.py b/doc/source/conf.py index 66ca024d4..f36dc533f 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -26,6 +26,7 @@ ) THIS_PATH = Path(__file__).parent.resolve() +PYANSYS_LIGHT_SQUARE = (THIS_PATH / "_static" / "pyansys_light_square.png").resolve() EXAMPLE_PATH = (THIS_PATH / "examples" / "sphinx_examples").resolve() # Project information @@ -270,7 +271,7 @@ def download_and_process_files(example_links: List[str]) -> List[str]: "download_all_examples": False, # Modules for which function level galleries are created. In "image_scrapers": ("pyvista", "matplotlib"), - "default_thumb_file": "source/_static/pyansys_light_square.png", + "default_thumb_file": str(PYANSYS_LIGHT_SQUARE), } nbsphinx_prolog = """ diff --git a/doc/source/contribute/developer.rst b/doc/source/contribute/developer.rst index 47f83eb06..a687e10b0 100644 --- a/doc/source/contribute/developer.rst +++ b/doc/source/contribute/developer.rst @@ -239,3 +239,9 @@ You can clean the build directory by running:: # On Windows doc\make.bat clean + +.. Note:: + + Use ``tox -e doc-serve`` to build the documentation and open it in your + default browser. This command will also watch for changes in the source + files and rebuild the documentation automatically. \ No newline at end of file diff --git a/package.json b/package.json index 893d26ffb..fc3d67b81 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,6 @@ { "name": "ansys_sphinx_theme", "repository": "https://github.com/ansys/ansys-sphinx-theme", - "description": "", "main": "", "scripts": { @@ -9,4 +8,4 @@ }, "dependencies": {}, "devDependencies": {} -} \ No newline at end of file +} diff --git a/pyproject.toml b/pyproject.toml index 91aba3f76..45109168f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = [ - "sphinx-theme-builder >= 0.2.0b2,<1", + "sphinx-theme-builder>=0.2.0b2,<1", ] build-backend = "sphinx_theme_builder" @@ -62,6 +62,7 @@ doc = [ "sphinx-jinja==2.0.2", "sphinx-notfound-page==1.1.0", "tox==4.24.1", + "sphinx-theme-builder[cli]==0.2.0b2", ] changelog = [ "PyYAML==6.0.2", @@ -163,4 +164,4 @@ showcontent = true [[tool.towncrier.type]] directory = "miscellaneous" name = "Miscellaneous" -showcontent = true \ No newline at end of file +showcontent = true diff --git a/tox.ini b/tox.ini index 944ebf4ba..3524367b7 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,7 @@ description = Default tox environments list envlist = code-style doc-style - doc-{links,html,pdf,clean} + doc-{links,html,pdf,clean,serve} dist skip_missing_interpreters = true isolated_build = true @@ -36,10 +36,12 @@ commands = vale sync --config="{toxinidir}/doc/.vale.ini" vale --config="{toxinidir}/doc/.vale.ini" "{toxinidir}/doc" -[testenv:doc-{clean,links,html,pdf}] +[testenv:doc-{clean,links,html,pdf,serve}] description = Checks documentation links and pages generates properly +skip_install = + clean: true allowlist_externals = - pdflatex + pdf: pdflatex extras = doc setenv = SOURCE_DIR = doc/source @@ -50,7 +52,8 @@ setenv = links,html,pdf: BUILDER_OPTS = --color -v -j auto -W --keep-going commands = links,html,pdf: sphinx-build -d "{toxworkdir}/doc_doctree" {env:SOURCE_DIR} "{toxinidir}/{env:BUILD_DIR}/{env:BUILDER}" {env:BUILDER_OPTS} -b {env:BUILDER} - clean: python -c "import shutil, sys; shutil.rmtree(sys.argv[1], ignore_errors=True)" "{toxinidir}/{env:BUILD_DIR}" + clean: python -c "import shutil, sys; shutil.rmtree(sys.argv[1], ignore_errors=True)" "{toxinidir}/{env:BUILD_DIR}" + serve: stb serve "{toxinidir}/{env:SOURCE_DIR}/" [testenv:dist] description = Checks project distribution @@ -58,4 +61,4 @@ skip_install = true deps = build commands = - python -m build {toxinidir} \ No newline at end of file + python -m build {toxinidir}