1c44ef7f9Sopenharmony_ciHow to contribute to MarkupSafe 2c44ef7f9Sopenharmony_ci=============================== 3c44ef7f9Sopenharmony_ci 4c44ef7f9Sopenharmony_ciThank you for considering contributing to MarkupSafe! 5c44ef7f9Sopenharmony_ci 6c44ef7f9Sopenharmony_ci 7c44ef7f9Sopenharmony_ciSupport questions 8c44ef7f9Sopenharmony_ci----------------- 9c44ef7f9Sopenharmony_ci 10c44ef7f9Sopenharmony_ciPlease don't use the issue tracker for this. The issue tracker is a tool 11c44ef7f9Sopenharmony_cito address bugs and feature requests in MarkupSafe itself. Use one of 12c44ef7f9Sopenharmony_cithe following resources for questions about using MarkupSafe or issues 13c44ef7f9Sopenharmony_ciwith your own code: 14c44ef7f9Sopenharmony_ci 15c44ef7f9Sopenharmony_ci- The ``#get-help`` channel on our Discord chat: 16c44ef7f9Sopenharmony_ci https://discord.gg/pallets 17c44ef7f9Sopenharmony_ci- The mailing list flask@python.org for long term discussion or larger 18c44ef7f9Sopenharmony_ci issues. 19c44ef7f9Sopenharmony_ci- Ask on `Stack Overflow`_. Search with Google first using: 20c44ef7f9Sopenharmony_ci ``site:stackoverflow.com markupsafe {search term, exception message, etc.}`` 21c44ef7f9Sopenharmony_ci 22c44ef7f9Sopenharmony_ci.. _Stack Overflow: https://stackoverflow.com/search?tab=relevance&q=markupsafe 23c44ef7f9Sopenharmony_ci 24c44ef7f9Sopenharmony_ci 25c44ef7f9Sopenharmony_ciReporting issues 26c44ef7f9Sopenharmony_ci---------------- 27c44ef7f9Sopenharmony_ci 28c44ef7f9Sopenharmony_ciInclude the following information in your post: 29c44ef7f9Sopenharmony_ci 30c44ef7f9Sopenharmony_ci- Describe what you expected to happen. 31c44ef7f9Sopenharmony_ci- If possible, include a `minimal reproducible example`_ to help us 32c44ef7f9Sopenharmony_ci identify the issue. This also helps check that the issue is not with 33c44ef7f9Sopenharmony_ci your own code. 34c44ef7f9Sopenharmony_ci- Describe what actually happened. Include the full traceback if there 35c44ef7f9Sopenharmony_ci was an exception. 36c44ef7f9Sopenharmony_ci- List your Python and MarkupSafe versions. If possible, check if this 37c44ef7f9Sopenharmony_ci issue is already fixed in the latest releases or the latest code in 38c44ef7f9Sopenharmony_ci the repository. 39c44ef7f9Sopenharmony_ci 40c44ef7f9Sopenharmony_ci.. _minimal reproducible example: https://stackoverflow.com/help/minimal-reproducible-example 41c44ef7f9Sopenharmony_ci 42c44ef7f9Sopenharmony_ci 43c44ef7f9Sopenharmony_ciSubmitting patches 44c44ef7f9Sopenharmony_ci------------------ 45c44ef7f9Sopenharmony_ci 46c44ef7f9Sopenharmony_ciIf there is not an open issue for what you want to submit, prefer 47c44ef7f9Sopenharmony_ciopening one for discussion before working on a PR. You can work on any 48c44ef7f9Sopenharmony_ciissue that doesn't have an open PR linked to it or a maintainer assigned 49c44ef7f9Sopenharmony_cito it. These show up in the sidebar. No need to ask if you can work on 50c44ef7f9Sopenharmony_cian issue that interests you. 51c44ef7f9Sopenharmony_ci 52c44ef7f9Sopenharmony_ciInclude the following in your patch: 53c44ef7f9Sopenharmony_ci 54c44ef7f9Sopenharmony_ci- Use `Black`_ to format your code. This and other tools will run 55c44ef7f9Sopenharmony_ci automatically if you install `pre-commit`_ using the instructions 56c44ef7f9Sopenharmony_ci below. 57c44ef7f9Sopenharmony_ci- Include tests if your patch adds or changes code. Make sure the test 58c44ef7f9Sopenharmony_ci fails without your patch. 59c44ef7f9Sopenharmony_ci- Update any relevant docs pages and docstrings. Docs pages and 60c44ef7f9Sopenharmony_ci docstrings should be wrapped at 72 characters. 61c44ef7f9Sopenharmony_ci- Add an entry in ``CHANGES.rst``. Use the same style as other 62c44ef7f9Sopenharmony_ci entries. Also include ``.. versionchanged::`` inline changelogs in 63c44ef7f9Sopenharmony_ci relevant docstrings. 64c44ef7f9Sopenharmony_ci 65c44ef7f9Sopenharmony_ci.. _Black: https://black.readthedocs.io 66c44ef7f9Sopenharmony_ci.. _pre-commit: https://pre-commit.com 67c44ef7f9Sopenharmony_ci 68c44ef7f9Sopenharmony_ci 69c44ef7f9Sopenharmony_ciFirst time setup 70c44ef7f9Sopenharmony_ci~~~~~~~~~~~~~~~~ 71c44ef7f9Sopenharmony_ci 72c44ef7f9Sopenharmony_ci- Download and install the `latest version of git`_. 73c44ef7f9Sopenharmony_ci- Configure git with your `username`_ and `email`_. 74c44ef7f9Sopenharmony_ci 75c44ef7f9Sopenharmony_ci .. code-block:: text 76c44ef7f9Sopenharmony_ci 77c44ef7f9Sopenharmony_ci $ git config --global user.name 'your name' 78c44ef7f9Sopenharmony_ci $ git config --global user.email 'your email' 79c44ef7f9Sopenharmony_ci 80c44ef7f9Sopenharmony_ci- Make sure you have a `GitHub account`_. 81c44ef7f9Sopenharmony_ci- Fork MarkupSafe to your GitHub account by clicking the `Fork`_ button. 82c44ef7f9Sopenharmony_ci- `Clone`_ the main repository locally. 83c44ef7f9Sopenharmony_ci 84c44ef7f9Sopenharmony_ci .. code-block:: text 85c44ef7f9Sopenharmony_ci 86c44ef7f9Sopenharmony_ci $ git clone https://github.com/pallets/markupsafe 87c44ef7f9Sopenharmony_ci $ cd markupsafe 88c44ef7f9Sopenharmony_ci 89c44ef7f9Sopenharmony_ci- Add your fork as a remote to push your work to. Replace 90c44ef7f9Sopenharmony_ci ``{username}`` with your username. This names the remote "fork", the 91c44ef7f9Sopenharmony_ci default Pallets remote is "origin". 92c44ef7f9Sopenharmony_ci 93c44ef7f9Sopenharmony_ci .. code-block:: text 94c44ef7f9Sopenharmony_ci 95c44ef7f9Sopenharmony_ci $ git remote add fork https://github.com/{username}/markupsafe 96c44ef7f9Sopenharmony_ci 97c44ef7f9Sopenharmony_ci- Create a virtualenv. 98c44ef7f9Sopenharmony_ci 99c44ef7f9Sopenharmony_ci .. code-block:: text 100c44ef7f9Sopenharmony_ci 101c44ef7f9Sopenharmony_ci $ python3 -m venv env 102c44ef7f9Sopenharmony_ci $ . env/bin/activate 103c44ef7f9Sopenharmony_ci 104c44ef7f9Sopenharmony_ci On Windows, activating is different. 105c44ef7f9Sopenharmony_ci 106c44ef7f9Sopenharmony_ci .. code-block:: text 107c44ef7f9Sopenharmony_ci 108c44ef7f9Sopenharmony_ci > env\Scripts\activate 109c44ef7f9Sopenharmony_ci 110c44ef7f9Sopenharmony_ci- Upgrade pip and setuptools. 111c44ef7f9Sopenharmony_ci 112c44ef7f9Sopenharmony_ci .. code-block:: text 113c44ef7f9Sopenharmony_ci 114c44ef7f9Sopenharmony_ci $ python -m pip install --upgrade pip setuptools 115c44ef7f9Sopenharmony_ci 116c44ef7f9Sopenharmony_ci- Install the development dependencies, then install MarkupSafe in 117c44ef7f9Sopenharmony_ci editable mode. 118c44ef7f9Sopenharmony_ci 119c44ef7f9Sopenharmony_ci .. code-block:: text 120c44ef7f9Sopenharmony_ci 121c44ef7f9Sopenharmony_ci $ pip install -r requirements/dev.txt && pip install -e . 122c44ef7f9Sopenharmony_ci 123c44ef7f9Sopenharmony_ci- Install the pre-commit hooks. 124c44ef7f9Sopenharmony_ci 125c44ef7f9Sopenharmony_ci .. code-block:: text 126c44ef7f9Sopenharmony_ci 127c44ef7f9Sopenharmony_ci $ pre-commit install 128c44ef7f9Sopenharmony_ci 129c44ef7f9Sopenharmony_ci.. _latest version of git: https://git-scm.com/downloads 130c44ef7f9Sopenharmony_ci.. _username: https://docs.github.com/en/github/using-git/setting-your-username-in-git 131c44ef7f9Sopenharmony_ci.. _email: https://docs.github.com/en/github/setting-up-and-managing-your-github-user-account/setting-your-commit-email-address 132c44ef7f9Sopenharmony_ci.. _GitHub account: https://github.com/join 133c44ef7f9Sopenharmony_ci.. _Fork: https://github.com/pallets/markupsafe/fork 134c44ef7f9Sopenharmony_ci.. _Clone: https://docs.github.com/en/github/getting-started-with-github/fork-a-repo#step-2-create-a-local-clone-of-your-fork 135c44ef7f9Sopenharmony_ci 136c44ef7f9Sopenharmony_ci 137c44ef7f9Sopenharmony_ciStart coding 138c44ef7f9Sopenharmony_ci~~~~~~~~~~~~ 139c44ef7f9Sopenharmony_ci 140c44ef7f9Sopenharmony_ci- Create a branch to identify the issue you would like to work on. If 141c44ef7f9Sopenharmony_ci you're submitting a bug or documentation fix, branch off of the 142c44ef7f9Sopenharmony_ci latest ".x" branch. 143c44ef7f9Sopenharmony_ci 144c44ef7f9Sopenharmony_ci .. code-block:: text 145c44ef7f9Sopenharmony_ci 146c44ef7f9Sopenharmony_ci $ git fetch origin 147c44ef7f9Sopenharmony_ci $ git checkout -b your-branch-name origin/2.0.x 148c44ef7f9Sopenharmony_ci 149c44ef7f9Sopenharmony_ci If you're submitting a feature addition or change, branch off of the 150c44ef7f9Sopenharmony_ci "main" branch. 151c44ef7f9Sopenharmony_ci 152c44ef7f9Sopenharmony_ci .. code-block:: text 153c44ef7f9Sopenharmony_ci 154c44ef7f9Sopenharmony_ci $ git fetch origin 155c44ef7f9Sopenharmony_ci $ git checkout -b your-branch-name origin/main 156c44ef7f9Sopenharmony_ci 157c44ef7f9Sopenharmony_ci- Using your favorite editor, make your changes, 158c44ef7f9Sopenharmony_ci `committing as you go`_. 159c44ef7f9Sopenharmony_ci- Include tests that cover any code changes you make. Make sure the 160c44ef7f9Sopenharmony_ci test fails without your patch. Run the tests as described below. 161c44ef7f9Sopenharmony_ci- Push your commits to your fork on GitHub and 162c44ef7f9Sopenharmony_ci `create a pull request`_. Link to the issue being addressed with 163c44ef7f9Sopenharmony_ci ``fixes #123`` in the pull request. 164c44ef7f9Sopenharmony_ci 165c44ef7f9Sopenharmony_ci .. code-block:: text 166c44ef7f9Sopenharmony_ci 167c44ef7f9Sopenharmony_ci $ git push --set-upstream fork your-branch-name 168c44ef7f9Sopenharmony_ci 169c44ef7f9Sopenharmony_ci.. _committing as you go: https://dont-be-afraid-to-commit.readthedocs.io/en/latest/git/commandlinegit.html#commit-your-changes 170c44ef7f9Sopenharmony_ci.. _create a pull request: https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request 171c44ef7f9Sopenharmony_ci 172c44ef7f9Sopenharmony_ci 173c44ef7f9Sopenharmony_ciRunning the tests 174c44ef7f9Sopenharmony_ci~~~~~~~~~~~~~~~~~ 175c44ef7f9Sopenharmony_ci 176c44ef7f9Sopenharmony_ciRun the basic test suite with pytest. 177c44ef7f9Sopenharmony_ci 178c44ef7f9Sopenharmony_ci.. code-block:: text 179c44ef7f9Sopenharmony_ci 180c44ef7f9Sopenharmony_ci $ pytest 181c44ef7f9Sopenharmony_ci 182c44ef7f9Sopenharmony_ciThis runs the tests for the current environment, which is usually 183c44ef7f9Sopenharmony_cisufficient. CI will run the full suite when you submit your pull 184c44ef7f9Sopenharmony_cirequest. You can run the full test suite with tox if you don't want to 185c44ef7f9Sopenharmony_ciwait. 186c44ef7f9Sopenharmony_ci 187c44ef7f9Sopenharmony_ci.. code-block:: text 188c44ef7f9Sopenharmony_ci 189c44ef7f9Sopenharmony_ci $ tox 190c44ef7f9Sopenharmony_ci 191c44ef7f9Sopenharmony_ci 192c44ef7f9Sopenharmony_ciRunning test coverage 193c44ef7f9Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~ 194c44ef7f9Sopenharmony_ci 195c44ef7f9Sopenharmony_ciGenerating a report of lines that do not have test coverage can indicate 196c44ef7f9Sopenharmony_ciwhere to start contributing. Run ``pytest`` using ``coverage`` and 197c44ef7f9Sopenharmony_cigenerate a report. 198c44ef7f9Sopenharmony_ci 199c44ef7f9Sopenharmony_ci.. code-block:: text 200c44ef7f9Sopenharmony_ci 201c44ef7f9Sopenharmony_ci $ pip install coverage 202c44ef7f9Sopenharmony_ci $ coverage run -m pytest 203c44ef7f9Sopenharmony_ci $ coverage html 204c44ef7f9Sopenharmony_ci 205c44ef7f9Sopenharmony_ciOpen ``htmlcov/index.html`` in your browser to explore the report. 206c44ef7f9Sopenharmony_ci 207c44ef7f9Sopenharmony_ciRead more about `coverage <https://coverage.readthedocs.io>`__. 208c44ef7f9Sopenharmony_ci 209c44ef7f9Sopenharmony_ci 210c44ef7f9Sopenharmony_ciBuilding the docs 211c44ef7f9Sopenharmony_ci~~~~~~~~~~~~~~~~~ 212c44ef7f9Sopenharmony_ci 213c44ef7f9Sopenharmony_ciBuild the docs in the ``docs`` directory using Sphinx. 214c44ef7f9Sopenharmony_ci 215c44ef7f9Sopenharmony_ci.. code-block:: text 216c44ef7f9Sopenharmony_ci 217c44ef7f9Sopenharmony_ci $ cd docs 218c44ef7f9Sopenharmony_ci $ make html 219c44ef7f9Sopenharmony_ci 220c44ef7f9Sopenharmony_ciOpen ``_build/html/index.html`` in your browser to view the docs. 221c44ef7f9Sopenharmony_ci 222c44ef7f9Sopenharmony_ciRead more about `Sphinx <https://www.sphinx-doc.org/en/stable/>`__. 223