Skip to content
Myr

reformat contributing doc

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent 295e1e7 · Browse files · 1 file+119 added−82 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+119 added−82 removed

  • other:+119 added−82 removed

1 file+119 added−82 removed

modified:CONTRIBUTING.rst+119 added-82 removed
1 unmodified line
2==========================34Thank you for considering contributing to Flask!567Support questions8-----------------910Please, don't use the issue tracker for this. Use one of the following11resources for questions about your own code:1212* The ``#get-help`` channel on our Discord chat: https://discordapp.com/invite/t6rrQZH13- The ``#get-help`` channel on our Discord chat:14 https://discord.gg/t6rrQZH1514 * The IRC channel ``#pocoo`` on FreeNode is linked to Discord, but15 Discord is preferred.16 - The IRC channel ``#pocoo`` on FreeNode is linked to Discord, but17 Discord is preferred.1819- The mailing list flask@python.org for long term discussion or larger17* The mailing list flask@python.org for long term discussion or larger issues.18* Ask on `Stack Overflow`_. Search with Google first using:19 ``site:stackoverflow.com flask {search term, exception message, etc.}``20 issues.21- Ask on `Stack Overflow`_. Search with Google first using:22 ``site:stackoverflow.com flask {search term, exception message, etc.}``2324.. _Stack Overflow: https://stackoverflow.com/questions/tagged/flask?sort=linked252627Reporting issues28----------------2926- Describe what you expected to happen.27- If possible, include a `minimal reproducible example`_ to help us28 identify the issue. This also helps check that the issue is not with29 your own code.30- Describe what actually happened. Include the full traceback if there was an31 exception.32- List your Python, Flask, and Werkzeug versions. If possible, check if this33 issue is already fixed in the repository.30- Describe what you expected to happen.31- If possible, include a `minimal reproducible example`_ to help us32 identify the issue. This also helps check that the issue is not with33 your own code.34- Describe what actually happened. Include the full traceback if there35 was an exception.36- List your Python, Flask, and Werkzeug versions. If possible, check37 if this issue is already fixed in the repository.3839.. _minimal reproducible example: https://stackoverflow.com/help/minimal-reproducible-example404142Submitting patches43------------------4440- Use `Black`_ to autoformat your code. This should be done for you as a41 git `pre-commit`_ hook, which gets installed when you run ``pip install -e .[dev]``.42 You may also wish to use Black's `Editor integration`_.43- Include tests if your patch is supposed to solve a bug, and explain44 clearly under which circumstances the bug happens. Make sure the test fails45 without your patch.46- Include a string like "Fixes #123" in your commit message47 (where 123 is the issue you fixed).48 See `Closing issues using keywords49 <https://help.github.com/articles/creating-a-pull-request/>`__.45- Use `Black`_ to autoformat your code. This should be done for you as46 a Git `pre-commit`_ hook, set up below. You may also wish to use47 Black's `Editor integration`_.48- Include tests if your patch is supposed to solve a bug, and explain49 clearly under which circumstances the bug happens. Make sure the50 test fails without your patch.51- Include a string like "Fixes #123" in your commit message (where 12352 is the issue you fixed). See `Closing issues using keywords53 <https://help.github.com/articles/creating-a-pull-request/>`__.545556First time setup57~~~~~~~~~~~~~~~~5854- Download and install the `latest version of git`_.55- Configure git with your `username`_ and `email`_::59- Download and install the `latest version of git`_.60- Configure git with your `username`_ and `email`_.6157 git config --global user.name 'your name'58 git config --global user.email 'your email'62 .. code-block:: text6360- Make sure you have a `GitHub account`_.61- Fork Flask to your GitHub account by clicking the `Fork`_ button.62- `Clone`_ your GitHub fork locally::64 $ git config --global user.name 'your name'65 $ git config --global user.email 'your email'6664 git clone https://github.com/{username}/flask65 cd flask67- Make sure you have a `GitHub account`_.68- Fork Flask to your GitHub account by clicking the `Fork`_ button.69- `Clone`_ your GitHub fork locally.7067- Add the main repository as a remote to update later::71 .. code-block:: text7273 $ git clone https://github.com/{username}/flask74 $ cd flask7576- Add the main repository as a remote to update later::7778 .. code-block:: text7980 git remote add pallets https://github.com/pallets/flask81 git fetch pallets8272- Create a virtualenv::83- Create a virtualenv.8474 python3 -m venv env75 . env/bin/activate76 # or "env\Scripts\activate" on Windows85 .. code-block:: text8678- Install Flask in editable mode with development dependencies::87 $ python3 -m venv env88 $ . env/bin/activate8980 pip install -e ".[dev]"90 On Windows, activating is different.9182- Install the `pre-commit framework`_.83- Install the pre-commit hooks::92 .. code-block:: text9385 pre-commit install --install-hooks94 > env\Scripts\activate9596- Install Flask in editable mode with development dependencies.9798 .. code-block:: text99100 $ pip install -e ".[dev]"101102- Install the `pre-commit framework`_.103- Install the pre-commit hooks.104105 .. code-block:: text106107 $ pre-commit install108109.. _GitHub account: https://github.com/join110.. _latest version of git: https://git-scm.com/downloads111.. _username: https://help.github.com/en/articles/setting-your-username-in-git112.. _email: https://help.github.com/en/articles/setting-your-commit-email-address-in-git113.. _Fork: https://github.com/pallets/flask/fork114.. _Clone: https://help.github.com/en/articles/fork-a-repo#step-2-create-a-local-clone-of-your-fork115.. _pre-commit framework: https://pre-commit.com/#install116117118Start coding119~~~~~~~~~~~~120121- Create a branch to identify the issue you would like to work on. If122 you're submitting a bug or documentation fix, branch off of the100 latest ".x" branch::123 latest ".x" branch.124102 git checkout -b your-branch-name origin/1.0.x125 .. code-block:: text126127 $ git checkout -b your-branch-name origin/1.0.x128129 If you're submitting a feature addition or change, branch off of the105 "master" branch::130 "master" branch.131107 git checkout -b your-branch-name origin/master132 .. code-block:: text133109- Using your favorite editor, make your changes, `committing as you go`_.110- Include tests that cover any code changes you make. Make sure the test fails111 without your patch. `Run the tests <contributing-testsuite_>`_.112- Push your commits to GitHub and `create a pull request`_ by using::134 $ git checkout -b your-branch-name origin/master135114 git push --set-upstream origin your-branch-name136- Using your favorite editor, make your changes,137 `committing as you go`_.138- Include tests that cover any code changes you make. Make sure the139 test fails without your patch.140 `Run the tests <contributing-testsuite_>`_.141- Push your commits to GitHub and `create a pull request`_.142116- Celebrate 🎉143 .. code-block:: text144145 $ git push --set-upstream origin your-branch-name146147.. _committing as you go: https://dont-be-afraid-to-commit.readthedocs.io/en/latest/git/commandlinegit.html#commit-your-changes148.. _Black: https://black.readthedocs.io149.. _Editor integration: https://black.readthedocs.io/en/stable/editor_integration.html150.. _pre-commit: https://pre-commit.com151.. _create a pull request: https://help.github.com/en/articles/creating-a-pull-request152153154.. _contributing-testsuite: #running-the-tests155156Running the tests157~~~~~~~~~~~~~~~~~158129Run the basic test suite with::159Run the basic test suite with pytest.160131 pytest161.. code-block:: text162133This only runs the tests for the current environment. Whether this is relevant134depends on which part of Flask you're working on. Travis-CI will run the full135suite when you submit your pull request.163 $ pytest164165This only runs the tests for the current environment. Whether this is166relevant depends on which part of Flask you're working on. CI will run167the full suite when you submit your pull request.168169The full test suite takes a long time to run because it tests multiple170combinations of Python and dependencies. If you don't have a Python171version installed, it will be skipped with a warning message at the end.140Run::172142 tox173.. code-block:: text174175 $ tox176177178Running test coverage179~~~~~~~~~~~~~~~~~~~~~180181Generating a report of lines that do not have test coverage can indicate148where to start contributing. Run ``pytest`` using ``coverage`` and generate a149report on the terminal and as an interactive HTML document::182where to start contributing. Run ``pytest`` using ``coverage`` and183generate a report on the terminal and as an interactive HTML document.184151 coverage run -m pytest152 coverage report153 coverage html154 # then open htmlcov/index.html185.. code-block:: text186187 $ coverage run -m pytest188 $ coverage report189 $ coverage html # then open htmlcov/index.html190191Read more about `coverage <https://coverage.readthedocs.io>`_.192193Running the full test suite with ``tox`` will combine the coverage reports194from all runs.
1 unmodified line
196197Building the docs198~~~~~~~~~~~~~~~~~199165Build the docs in the ``docs`` directory using Sphinx::200Build the docs in the ``docs`` directory using Sphinx.201167 cd docs168 pip install -r requirements.txt169 make html202.. code-block:: text203204 $ cd docs205 $ make html206207Open ``_build/html/index.html`` in your browser to view the docs.208209Read more about `Sphinx <https://www.sphinx-doc.org/en/master/>`_.210211212Caution: zero-padded file modes213-------------------------------214179This repository contains several zero-padded file modes that may cause issues180when pushing this repository to git hosts other than GitHub. Fixing this is181destructive to the commit history, so we suggest ignoring these warnings. If it182fails to push and you're using a self-hosted git service like GitLab, you can183turn off repository checks in the admin panel.215This repository contains several zero-padded file modes that may cause216issues when pushing this repository to Git hosts other than GitHub.217Fixing this is destructive to the commit history, so we suggest ignoring218these warnings. If it fails to push and you're using a self-hosted Git219service like GitLab, you can turn off repository checks in the admin220panel.221185These files can also cause issues while cloning. If you have ::222These files can also cause issues while cloning if you have223``fsckObjects`` enabled with either of the following in your git config.224225.. code-block::226227 [fetch]188 fsckobjects = true228 fsckObjects = true229190or ::191230 [receive]231 fsckObjects = true232195set in your git configuration file, cloning this repository will fail. The only196solution is to set both of the above settings to false while cloning, and then197setting them back to true after the cloning is finished.233The only solution is to set both of the above to ``false``, clone, and234then set them back to ``true`` after.