.. _contributing: ================== Contributing Guide ================== We appreciate your help in improving this document and our library! Please `open an issue `_ if you face any problems or have suggestions for improvements. We are always happy to help. .. _development-workflow: If you are interested in contributing code or documentation, we strongly recommend that you install a development version of myst-sphinx-gallery in a development environment. If you are unfamiliar with the git/github workflow, please see Github's guide to `contributing to projects `_. This guide assumes familiarity with the Github workflow and focuses on aspects specific to contributing to MyST-Sphinx-Gallery. .. _checkout-source: Get Latest Source Code ---------------------- You can get the latest development source from our `Github repository `_. Fork the repository and clone it to your local machine: .. code-block:: bash git clone https://github.com//myst-sphinx-gallery .. _virtual-environment: Create a Dedicated Environment ------------------------------ We strongly recommend that you create a virtual environment for developing MyST Sphinx Gallery to isolate it from other Python installations on your system. Create a new virtual environment using `venv `_: .. code-block:: bash python -m venv myst_gallery Activate the environment: .. code-block:: bash source /bin/activate # Linux/macOS \Scripts\activate.bat # Windows cmd.exe \Scripts\Activate.ps1 or using `conda `_: .. code-block:: bash conda create -n myst_gallery python=3.10 Activate the environment: .. code-block:: bash conda activate myst_gallery .. _install-dependencies: Install Dependencies -------------------- Most of the MyST Sphinx Gallery dependencies are listed in :file:`pyproject.toml` and can be installed from those files: .. code-block:: bash python -m pip install ".[dev]" MyST Sphinx Gallery requires that `setuptools `_ is installed. It is usually packaged with python, but if necessary can be installed using ``pip``: .. code-block:: bash python -m pip install setuptools .. _editable-install: Install for Development ----------------------- Editable installs means that the environment Python will always use the most recently changed version of your code. To install MyST Sphinx Gallery in editable mode, ensure you are in the sphinx-gallery directory .. code-block:: bash cd myst-sphinx-gallery Then install using the editable flag: .. code-block:: bash python -m pip install -e . .. _verify-install: Verify install -------------- Check that you are all set by running the tests: .. code-block:: bash python -m pytest myst-sphinx_gallery And by building the docs: .. code-block:: bash cd docs make html After building the docs, you can view them by opening :file:`_build/html/index.html` in your browser. To clean up the build files and generated galleries, run: .. code-block:: bash make clean .. _pre-commit-hooks: Install ruff and pre-commit --------------------------- To ensure that code contributions conform to style guide, we use the `ruff `_ tool to check for common mistakes and uniform code style. The `pre-commit `_ is used to run these checks automatically while committing code. To install ruff and pre-commit: .. code-block:: bash python -m pip install ruff pre-commit To run ruff on all files in the repository: .. code-block:: bash ruff check . To install pre-commit hooks, which will run all checks on all files before each commit, run: .. code-block:: bash pre-commit install Testing ------- All code contributions should be tested. We use the `pytest `_ testing framework to build test pages. Tests can be found in :file:`myst_sphinx_gallery/tests`.