|
| 1 | +Contributing as a developer |
| 2 | +########################### |
| 3 | + |
| 4 | +.. grid:: 1 1 3 3 |
| 5 | + |
| 6 | + .. grid-item-card:: :fa:`code-fork` Fork the repository |
| 7 | + :padding: 2 2 2 2 |
| 8 | + :link: fork-the-repository |
| 9 | + :link-type: ref |
| 10 | + |
| 11 | + Learn how to fork the project and get your own copy. |
| 12 | + |
| 13 | + .. grid-item-card:: :fa:`download` Clone the repository |
| 14 | + :padding: 2 2 2 2 |
| 15 | + :link: clone-the-repository |
| 16 | + :link-type: ref |
| 17 | + |
| 18 | + Download your own copy in your local machine. |
| 19 | + |
| 20 | + .. grid-item-card:: :fa:`download` Install for developers |
| 21 | + :padding: 2 2 2 2 |
| 22 | + :link: install-for-developers |
| 23 | + :link-type: ref |
| 24 | + |
| 25 | + Install the project in editable mode. |
| 26 | + |
| 27 | + |
| 28 | +.. _fork-the-repository: |
| 29 | + |
| 30 | +Fork the repository |
| 31 | +=================== |
| 32 | + |
| 33 | +Forking the repository is the first step for contributing to the project. This |
| 34 | +allows you to have your own copy of the project so you can make changes without |
| 35 | +affection the main project. Once you have made your changes, you can submit a |
| 36 | +pull-request to the main project to have your changes reviewed and merged. |
| 37 | + |
| 38 | +.. button-link:: https://github.com/ansys/ansys-sphinx-theme/fork |
| 39 | + :color: primary |
| 40 | + :align: center |
| 41 | + |
| 42 | + :fa:`code-fork` Fork this project |
| 43 | + |
| 44 | +.. note:: |
| 45 | + |
| 46 | + If you are an Ansys employee, you can skip this step. |
| 47 | + |
| 48 | +.. _clone-the-repository: |
| 49 | + |
| 50 | +Clone the repository |
| 51 | +==================== |
| 52 | + |
| 53 | +Make sure you `configure SSH`_ with your GitHub |
| 54 | +account. This allows you to clone the repository without having to use tokens |
| 55 | +or passwords. Also, make sure you have `git`_ installed in your machine. |
| 56 | + |
| 57 | +To clone the repository using SSH, run: |
| 58 | + |
| 59 | +.. code-block:: bash |
| 60 | +
|
| 61 | + git clone [email protected]:ansys/ansys-sphinx-theme |
| 62 | +
|
| 63 | +.. _install-for-developers: |
| 64 | + |
| 65 | +Install for developers |
| 66 | +====================== |
| 67 | + |
| 68 | +Installing Ansys sphinx theme in development mode allows you to perform changes to the code |
| 69 | +and see the changes reflected in your environment without having to reinstall |
| 70 | +the library every time you make a change. |
| 71 | + |
| 72 | +Virtual environment |
| 73 | +------------------- |
| 74 | + |
| 75 | +Start by navigating to the project's root directory by running: |
| 76 | + |
| 77 | +.. code-block:: bash |
| 78 | +
|
| 79 | + cd ansys-sphinx-theme |
| 80 | +
|
| 81 | +Then, create a new virtual environment named ``.venv`` to isolate your system's |
| 82 | +Python environment by running: |
| 83 | + |
| 84 | +.. code-block:: bash |
| 85 | +
|
| 86 | + python -m venv .venv |
| 87 | +
|
| 88 | +Finally, activate this environment by running: |
| 89 | + |
| 90 | +.. tab-set:: |
| 91 | + |
| 92 | + .. tab-item:: Windows |
| 93 | + |
| 94 | + .. tab-set:: |
| 95 | + |
| 96 | + .. tab-item:: CMD |
| 97 | + |
| 98 | + .. code-block:: bash |
| 99 | +
|
| 100 | + .venv\Scripts\activate.bat |
| 101 | +
|
| 102 | + .. tab-item:: PowerShell |
| 103 | + |
| 104 | + .. code-block:: bash |
| 105 | +
|
| 106 | + .venv\Scripts\Activate.ps1 |
| 107 | +
|
| 108 | + .. tab-item:: macOS/Linux/UNIX |
| 109 | + |
| 110 | + .. code-block:: bash |
| 111 | +
|
| 112 | + source .venv/bin/activate |
| 113 | +
|
| 114 | +Development mode |
| 115 | +---------------- |
| 116 | + |
| 117 | +Now, install Ansys sphinx theme in editable mode by running: |
| 118 | + |
| 119 | +.. code-block:: bash |
| 120 | +
|
| 121 | + python -m pip install --editable . |
| 122 | +
|
| 123 | +Verify the installation by checking the version of the library: |
| 124 | + |
| 125 | + |
| 126 | +.. code-block:: python |
| 127 | +
|
| 128 | + from ansys_sphinx_theme import __version__ |
| 129 | + print(f"Ansys sphinx thenme version is {__version__}") |
| 130 | +
|
| 131 | +.. jinja:: |
| 132 | + |
| 133 | + .. code-block:: bash |
| 134 | +
|
| 135 | + >>> Ansys sphinx theme version is {{ ANSYS_SPHINX_THEME_VERSION }} |
| 136 | +
|
| 137 | +Install ``Tox`` |
| 138 | +--------------- |
| 139 | + |
| 140 | +Once the project is installed, you can install `Tox`_. This is a cross-platform |
| 141 | +automation tool. The main advantage of Tox is that it allows you to test your |
| 142 | +project in different environments and configurations in a temporary and |
| 143 | +isolated Python virtual environment. To install Tox, run: |
| 144 | + |
| 145 | +.. code-block:: bash |
| 146 | +
|
| 147 | + python -m pip install tox |
| 148 | +
|
| 149 | +Finally, verify the installation by listing all the different environments |
| 150 | +(automation rules) for Ansys Sphinx theme: |
| 151 | + |
| 152 | +.. code-block:: bash |
| 153 | +
|
| 154 | + python -m tox list |
| 155 | +
|
| 156 | +.. jinja:: toxenvs |
| 157 | + |
| 158 | + .. dropdown:: Default Tox environments |
| 159 | + :animate: fade-in |
| 160 | + :icon: three-bars |
| 161 | + |
| 162 | + .. list-table:: |
| 163 | + :header-rows: 1 |
| 164 | + :widths: auto |
| 165 | + |
| 166 | + * - Environment |
| 167 | + - Description |
| 168 | + - usage |
| 169 | + {% for environment in envs %} |
| 170 | + {% set name, description = environment.split("->") %} |
| 171 | + * - {{ name }} |
| 172 | + - {{ description }} |
| 173 | + - python -m tox -e {{ name }} |
| 174 | + {% endfor %} |
| 175 | + |
| 176 | + |
| 177 | +Adhere to code style |
| 178 | +-------------------- |
| 179 | + |
| 180 | +Ansys Sphinx theme follows the PEP8 standard as outlined in |
| 181 | +`PEP 8 <https://dev.docs.pyansys.com/coding-style/pep8.html>`_ in |
| 182 | +the *PyAnsys Developer's Guide* and implements style checking using |
| 183 | +`pre-commit <https://pre-commit.com/>`_. |
| 184 | + |
| 185 | +To ensure your code meets minimum code styling standards, run these commands:: |
| 186 | + |
| 187 | + pip install pre-commit |
| 188 | + pre-commit run --all-files |
| 189 | + |
| 190 | +or use tox as above:: |
| 191 | + |
| 192 | + tox -e code-style |
| 193 | + |
| 194 | +You can also install this as a pre-commit hook by running this command:: |
| 195 | + |
| 196 | + pre-commit install |
| 197 | + |
| 198 | +This way, it's not possible for you to push code that fails the style checks:: |
| 199 | + |
| 200 | + $ pre-commit install |
| 201 | + $ git commit -am "added my cool feature" |
| 202 | + ruff.....................................................................Passed |
| 203 | + ruff-format..............................................................Passed |
| 204 | + codespell................................................................Passed |
| 205 | + prettier.................................................................Passed |
| 206 | + check for merge conflicts................................................Passed |
| 207 | + debug statements (python)................................................Passed |
| 208 | + check yaml...............................................................Passed |
| 209 | + trim trailing whitespace.................................................Passed |
| 210 | + Validate GitHub Workflows................................................Passed |
| 211 | + Add License Headers......................................................Passed |
| 212 | + |
| 213 | + |
| 214 | +Build the documentation |
| 215 | +----------------------- |
| 216 | + |
| 217 | +To build documentation locally, you can either use Tox as mentioned above or |
| 218 | +run the following commands: |
| 219 | + |
| 220 | +1. Install the required dependencies by running:: |
| 221 | + |
| 222 | + python -m pip install -e .[doc] |
| 223 | + |
| 224 | +2. Build the documentation by running:: |
| 225 | + |
| 226 | + # On Linux or macOS |
| 227 | + make -C doc/ html |
| 228 | + |
| 229 | + # On Windows |
| 230 | + doc\make.bat html |
| 231 | + |
| 232 | +3. The documentation is built in the ``doc/_build/html`` directory. Open the |
| 233 | + ``index.html`` file in your browser to view the documentation. |
| 234 | + |
| 235 | +You can clean the build directory by running:: |
| 236 | + |
| 237 | + # On Linux or macOS |
| 238 | + make -C doc/ clean |
| 239 | + |
| 240 | + # On Windows |
| 241 | + doc\make.bat clean |
0 commit comments