From de8cd6a085ac3a42904d20f2ec9179bc25f608b9 Mon Sep 17 00:00:00 2001 From: Patrick Kunzmann Date: Thu, 4 Jan 2024 12:16:47 +0100 Subject: [PATCH 1/3] Change syntax for visualization with Ammolite --- doc/contribute.rst | 6 +++--- doc/examples/scripts/structure/biological_assembly.py | 2 +- doc/examples/scripts/structure/contact_sites.py | 2 +- doc/examples/scripts/structure/docking.py | 2 +- doc/examples/scripts/structure/leaflet.py | 2 +- doc/examples/scripts/structure/peptide_assembly.py | 2 +- doc/scraper.py | 6 +++--- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/contribute.rst b/doc/contribute.rst index 3ff4b1020..7e7c8cfed 100644 --- a/doc/contribute.rst +++ b/doc/contribute.rst @@ -188,7 +188,7 @@ corresponding code block: .. code-block:: python - # biotite_static_image = .png + # sphinx_gallery_static_image = .png The image file must be stored in the same directory as the example script. @@ -203,10 +203,10 @@ The visualization is initiated by adding the comment line .. code-block:: python - # Visualization with PyMOL.. + # sphinx_gallery_ammolite_script = .py in the code block where you want show the visualization. -Then the visualization script ``_pymol.py`` is executed, which +Then the visualization script ``.py`` is executed, which can use the global variables from the example script and the special ``__image_destination__`` variable. ``__image_destination__`` is a string representing the path to the output image diff --git a/doc/examples/scripts/structure/biological_assembly.py b/doc/examples/scripts/structure/biological_assembly.py index 87453122d..8dbd0e2a2 100644 --- a/doc/examples/scripts/structure/biological_assembly.py +++ b/doc/examples/scripts/structure/biological_assembly.py @@ -75,6 +75,6 @@ temp = NamedTemporaryFile(suffix=".cif") strucio.save_structure(temp.name, biological_unit) # Visualization with PyMOL... -# sphinx_gallery_pymol_image +# sphinx_gallery_ammolite_script = "biological_assembly_pymol.py" temp.close() \ No newline at end of file diff --git a/doc/examples/scripts/structure/contact_sites.py b/doc/examples/scripts/structure/contact_sites.py index 5aa3975d2..d7c14c71e 100644 --- a/doc/examples/scripts/structure/contact_sites.py +++ b/doc/examples/scripts/structure/contact_sites.py @@ -78,4 +78,4 @@ print(res_name.capitalize() + str(res_id)) # Visualization with PyMOL... -# sphinx_gallery_pymol_image \ No newline at end of file +# sphinx_gallery_ammolite_script = "contact_sites_pymol.py" diff --git a/doc/examples/scripts/structure/docking.py b/doc/examples/scripts/structure/docking.py index d1ba250a0..ae469e8e7 100644 --- a/doc/examples/scripts/structure/docking.py +++ b/doc/examples/scripts/structure/docking.py @@ -148,4 +148,4 @@ # Visualization with PyMOL... # sphinx_gallery_thumbnail_number = 2 -# sphinx_gallery_pymol_image \ No newline at end of file +# sphinx_gallery_ammolite_script = "docking_pymol.py" \ No newline at end of file diff --git a/doc/examples/scripts/structure/leaflet.py b/doc/examples/scripts/structure/leaflet.py index 6994b1cbe..ed31145e0 100644 --- a/doc/examples/scripts/structure/leaflet.py +++ b/doc/examples/scripts/structure/leaflet.py @@ -112,6 +112,6 @@ def find_leaflets(structure, head_atom_mask, temp = NamedTemporaryFile(suffix=".pdb") strucio.save_structure(temp.name, structure) # Visualization with PyMOL... -# sphinx_gallery_pymol_image +# sphinx_gallery_ammolite_script = "leaflet_pymol.py" temp.close() diff --git a/doc/examples/scripts/structure/peptide_assembly.py b/doc/examples/scripts/structure/peptide_assembly.py index 34576b170..7e6be4faf 100644 --- a/doc/examples/scripts/structure/peptide_assembly.py +++ b/doc/examples/scripts/structure/peptide_assembly.py @@ -253,6 +253,6 @@ def assemble_peptide(sequence): out_file = NamedTemporaryFile(suffix=".mmtf", delete=False) strucio.save_structure(out_file.name, chain) # Visualization with PyMOL... -# sphinx_gallery_pymol_image +# sphinx_gallery_ammolite_script = "peptide_assembly_pymol.py" out_file.close() diff --git a/doc/scraper.py b/doc/scraper.py index 45c5b0d24..5b7daf141 100644 --- a/doc/scraper.py +++ b/doc/scraper.py @@ -1,4 +1,3 @@ -from glob import glob import shutil import copy import sys @@ -10,7 +9,7 @@ STATIC_IMAGE_COMMAND = "static_image" -PYMOL_IMAGE_COMMAND = "pymol_image" +PYMOL_IMAGE_COMMAND = "ammolite_script" def static_image_scraper(block, block_vars, gallery_conf): @@ -51,7 +50,8 @@ def pymol_scraper(block, block_vars, gallery_conf): if PYMOL_IMAGE_COMMAND not in block_conf: return figure_rst([], gallery_conf['src_dir']) - pymol_script_path = splitext(block_vars["src_file"])[0] + "_pymol.py" + script_dir = dirname(block_vars["src_file"]) + pymol_script_path = join(script_dir, block_conf[PYMOL_IMAGE_COMMAND]) # The rendered image will be created in the same directory as # the example script # -> the image will be included in version control From 9ecdeb23c30f3c5de5adae2f7332648903e2ff84 Mon Sep 17 00:00:00 2001 From: Patrick Kunzmann Date: Thu, 4 Jan 2024 12:17:01 +0100 Subject: [PATCH 2/3] Remove config comments --- doc/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/conf.py b/doc/conf.py index 2d6f14af8..f44c73a1c 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -164,7 +164,7 @@ "doc_module" : ("biotite",), # Set the NCBI API key "reset_modules" : (key.set_ncbi_api_key_from_env,), - "remove_config_comments" : False, + "remove_config_comments" : True, } From 7738d9d31e5c16c8ee1c93f4961b627a763c3bc5 Mon Sep 17 00:00:00 2001 From: Patrick Kunzmann Date: Thu, 4 Jan 2024 12:17:24 +0100 Subject: [PATCH 3/3] Do not use cached files --- .github/workflows/test_and_deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 58c2b5a3a..80e31782f 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -192,7 +192,7 @@ jobs: - name: Install distribution run: pip install .//dist//*.whl - name: Build base documentation - run: sphinx-build -D plot_gallery=0 doc build//doc + run: sphinx-build -a -D plot_gallery=0 doc build//doc - name: Build tutorial and gallery if: > ( @@ -200,7 +200,7 @@ jobs: github.event.action == 'published' ) || github.event_name == 'workflow_dispatch' - run: sphinx-build doc build//doc + run: sphinx-build -a doc build//doc - name: Zip documentation run: | cd build