diff --git a/doc/devel/coding_guide.rst b/doc/devel/coding_guide.rst index 061af298efe2..3e9788ade101 100644 --- a/doc/devel/coding_guide.rst +++ b/doc/devel/coding_guide.rst @@ -13,8 +13,92 @@ Pull request guidelines *********************** -Pull requests (PRs) are the mechanism for contributing to Matplotlibs code and -documentation. +`Pull requests (PRs) on GitHub +`__ +are the mechanism for contributing to Matplotlib's code and documentation. + +It is recommended to check that your contribution complies with the following +rules before submitting a pull request: + +* If your pull request addresses an issue, please use the title to describe the + issue (e.g. "Add ability to plot timedeltas") and mention the issue number + in the pull request description to ensure that a link is created to the + original issue (e.g. "Closes #8869" or "Fixes #8869"). This will ensure the + original issue mentioned is automatically closed when your PR is merged. See + `the GitHub documentation + `__ + for more details. + +* Formatting should follow the recommendations of PEP8_, as enforced by + flake8_. You can check flake8 compliance from the command line with :: + + python -m pip install flake8 + flake8 /path/to/module.py + + or your editor may provide integration with it. Note that Matplotlib + intentionally does not use the black_ auto-formatter (1__), in particular due + to its unability to understand the semantics of mathematical expressions + (2__, 3__). + + .. _PEP8: https://www.python.org/dev/peps/pep-0008/ + .. _flake8: https://flake8.pycqa.org/ + .. _black: https://black.readthedocs.io/ + .. __: https://github.com/matplotlib/matplotlib/issues/18796 + .. __: https://github.com/psf/black/issues/148 + .. __: https://github.com/psf/black/issues/1984 + +* All public methods should have informative docstrings with sample usage when + appropriate. Use the :ref:`docstring standards `. + +* For high-level plotting functions, consider adding a simple example either in + the ``Example`` section of the docstring or the + :ref:`examples gallery `. + +* Changes (both new features and bugfixes) should have good test coverage. See + :ref:`testing` for more details. + +* Import the following modules using the standard scipy conventions:: + + import numpy as np + import numpy.ma as ma + import matplotlib as mpl + import matplotlib.pyplot as plt + import matplotlib.cbook as cbook + import matplotlib.patches as mpatches + + In general, Matplotlib modules should **not** import `.rcParams` using ``from + matplotlib import rcParams``, but rather access it as ``mpl.rcParams``. This + is because some modules are imported very early, before the `.rcParams` + singleton is constructed. + +* If your change is a major new feature, add an entry to the ``What's new`` + section by adding a new file in ``doc/users/next_whats_new`` (see + :file:`doc/users/next_whats_new/README.rst` for more information). + +* If you change the API in a backward-incompatible way, please document it in + :file:`doc/api/next_api_changes/behavior`, by adding a new file with the + naming convention ``99999-ABC.rst`` where the pull request number is followed + by the contributor's initials. (see :file:`doc/api/api_changes.rst` for more + information) + +* See below for additional points about :ref:`keyword-argument-processing`, if + applicable for your pull request. + +.. note:: + + The current state of the Matplotlib code base is not compliant with all + of these guidelines, but we expect that enforcing these constraints on all + new contributions will move the overall code base quality in the right + direction. + + +.. seealso:: + + * :ref:`coding_guidelines` + * :ref:`testing` + * :ref:`documenting-matplotlib` + + Summary for pull request authors ================================ diff --git a/doc/devel/contributing.rst b/doc/devel/contributing.rst index 6bd7f2610687..17a7e3e9dfe3 100644 --- a/doc/devel/contributing.rst +++ b/doc/devel/contributing.rst @@ -4,13 +4,20 @@ Contributing ============ +You've discovered a bug or something else you want to change +in Matplotlib — excellent! + +You've worked out a way to fix it — even better! + +You want to tell us about it — best of all! + This project is a community effort, and everyone is welcome to contribute. Everyone within the community is expected to abide by our `code of conduct `_. -The project is hosted on -https://github.com/matplotlib/matplotlib +Below, you can find a number of ways to contribute, and how to connect with the +Matplotlib community. Get Connected ============= @@ -192,96 +199,8 @@ A brief overview is: Finally, go to the web page of your fork of the Matplotlib repo, and click 'Pull request' to send your changes to the maintainers for review. -.. seealso:: - - * `Git documentation `_ - * `Git-Contributing to a Project `_ - * `Introduction to GitHub `_ - * :ref:`development-workflow` for best practices for Matplotlib - * :ref:`using-git` - -Contributing pull requests --------------------------- - -It is recommended to check that your contribution complies with the following -rules before submitting a pull request: - -* If your pull request addresses an issue, please use the title to describe the - issue and mention the issue number in the pull request description to ensure - that a link is created to the original issue. - -* All public methods should have informative docstrings with sample usage when - appropriate. Use the `numpy docstring standard - `_. - -* Formatting should follow the recommendations of PEP8_, as enforced by - flake8_. You can check flake8 compliance from the command line with :: - - python -m pip install flake8 - flake8 /path/to/module.py - - or your editor may provide integration with it. Note that Matplotlib - intentionally does not use the black_ auto-formatter (1__), in particular due - to its inability to understand the semantics of mathematical expressions - (2__, 3__). - - .. _PEP8: https://www.python.org/dev/peps/pep-0008/ - .. _flake8: https://flake8.pycqa.org/ - .. _black: https://black.readthedocs.io/ - .. __: https://github.com/matplotlib/matplotlib/issues/18796 - .. __: https://github.com/psf/black/issues/148 - .. __: https://github.com/psf/black/issues/1984 - -* Each high-level plotting function should have a simple example in the - ``Example`` section of the docstring. This should be as simple as possible - to demonstrate the method. More complex examples should go in the - ``examples`` tree. - -* Changes (both new features and bugfixes) should have good test coverage. See - :ref:`testing` for more details. - -* Import the following modules using the standard scipy conventions:: - - import numpy as np - import numpy.ma as ma - import matplotlib as mpl - import matplotlib.pyplot as plt - import matplotlib.cbook as cbook - import matplotlib.patches as mpatches - - In general, Matplotlib modules should **not** import `.rcParams` using ``from - matplotlib import rcParams``, but rather access it as ``mpl.rcParams``. This - is because some modules are imported very early, before the `.rcParams` - singleton is constructed. - -* If your change is a major new feature, add an entry to the ``What's new`` - section by adding a new file in ``doc/users/next_whats_new`` (see - :file:`doc/users/next_whats_new/README.rst` for more information). - -* If you change the API in a backward-incompatible way, please document it in - :file:`doc/api/next_api_changes/behavior`, by adding a new file with the - naming convention ``99999-ABC.rst`` where the pull request number is followed - by the contributor's initials. (see :file:`doc/api/api_changes.rst` for more - information) - -* See below for additional points about :ref:`keyword-argument-processing`, if - applicable for your pull request. - -.. note:: - - The current state of the Matplotlib code base is not compliant with all - of those guidelines, but we expect that enforcing those constraints on all - new contributions will move the overall code base quality in the right - direction. - - -.. seealso:: - - * :ref:`coding_guidelines` - * :ref:`testing` - * :ref:`documenting-matplotlib` - - +For more detailed instructions on how to set up Matplotlib for development and +best practices for contribution, see :ref:`installing_for_devs`. .. _contributing_documentation: diff --git a/doc/devel/development_setup.rst b/doc/devel/development_setup.rst index 81939e2474dc..f699b8579ea7 100644 --- a/doc/devel/development_setup.rst +++ b/doc/devel/development_setup.rst @@ -9,13 +9,22 @@ To set up Matplotlib for development follow these steps: .. contents:: :local: +Fork the Matplotlib repository +============================== + +Matplotlib is hosted at https://github.com/matplotlib/matplotlib.git. If you +plan on solving issues or submit pull requests to the main Matplotlib +repository, you should first *fork* this repository by visiting +https://github.com/matplotlib/matplotlib.git and clicking on the +``Fork`` button on the top right of the page (see +`the GitHub documentation `__ for more details.) + Retrieve the latest version of the code ======================================= -Matplotlib is hosted at https://github.com/matplotlib/matplotlib.git. - -You can retrieve the latest sources with the command (see -:ref:`set-up-fork` for more details) +Now that your fork of the repository lives under your GitHub username, you can +retrieve the latest sources with one of the following commands (where your +should replace ```` with your GitHub username): .. tab-set:: @@ -23,24 +32,40 @@ You can retrieve the latest sources with the command (see .. code-block:: bash - git clone https://github.com/matplotlib/matplotlib.git + git clone https://github.com//matplotlib.git .. tab-item:: ssh .. code-block:: bash - git clone git@github.com:matplotlib/matplotlib.git + git clone git@github.com:/matplotlib.git This requires you to setup an `SSH key`_ in advance, but saves you from typing your password at every connection. .. _SSH key: https://docs.github.com/en/authentication/connecting-to-github-with-ssh + This will place the sources in a directory :file:`matplotlib` below your -current working directory. Change into this directory:: +current working directory, set up the ``origin`` remote to point to your own +fork, and set up the ``upstream`` remote to point to the Matplotlib main +repository (see also `Managing remote repositories `__.) +Change into this directory before continuing:: cd matplotlib +.. note:: + + For more information on ``git`` and ``GitHub``, check the following resources. + + * `Git documentation `_ + * `GitHub-Contributing to a Project `_ + * `Introduction to GitHub `_ + * :ref:`using-git` + * :ref:`git-resources` + * `Installing git `_ + * https://tacaswell.github.io/think-like-git.html + * https://tom.preston-werner.com/2009/05/19/the-git-parable.html .. _dev-environment: @@ -86,12 +111,8 @@ The simplest way to do this is to use either Python's virtual environment Remember to activate the environment whenever you start working on Matplotlib. -Install additional development dependencies -=========================================== -See :ref:`development-dependencies`. - -Install Matplotlib in editable mode -=================================== +Installing Matplotlib in editable mode +====================================== Install Matplotlib in editable mode from the :file:`matplotlib` directory using the command :: @@ -105,6 +126,10 @@ true for ``*.py`` files. If you change the C-extension source (which might also happen if you change branches) you will have to re-run ``python -m pip install -ve .`` +Install additional development dependencies +=========================================== +See :ref:`development-dependencies`. + Install pre-commit hooks (optional) =================================== `pre-commit `_ hooks automatically check flake8 and diff --git a/doc/devel/gitwash/development_workflow.rst b/doc/devel/development_workflow.rst similarity index 56% rename from doc/devel/gitwash/development_workflow.rst rename to doc/devel/development_workflow.rst index d2917230d3ad..cf74012d81b6 100644 --- a/doc/devel/gitwash/development_workflow.rst +++ b/doc/devel/development_workflow.rst @@ -6,57 +6,46 @@ Development workflow #################### -You already have your own forked copy of the `Matplotlib`_ repository, by -following :ref:`forking`. You have :ref:`set-up-fork`. You have configured -git by following :ref:`configure-git`. Now you are ready for some real work. - Workflow summary ================ -In what follows we'll refer to the upstream Matplotlib ``main`` branch, as -"trunk". +To keep your work well organized, with readable history, and in turn make it +easier for project maintainers (that might be you) to see what you've done, and +why you did it, we recommend the following: * Don't use your ``main`` branch for anything. Consider deleting it. -* When you are starting a new set of changes, fetch any changes from trunk, - and start a new *feature branch* from that. -* Make a new branch for each separable set of changes |emdash| "one task, one - branch" (`ipython git workflow`_). +* Before starting a new set of changes, fetch all changes from + ``upstream/main``, and start a new *feature branch* from that. +* Make a new branch for each feature or bug fix — "one task, one branch". * Name your branch for the purpose of the changes - e.g. ``bugfix-for-issue-14`` or ``refactor-database-code``. -* If you can possibly avoid it, avoid merging trunk or any other branches into - your feature branch while you are working. -* If you do find yourself merging from trunk, consider :ref:`rebase-on-trunk` -* Ask on the `Matplotlib mailing list`_ if you get stuck. -* Ask for code review! - -This way of working helps to keep work well organized, with readable history. -This in turn makes it easier for project maintainers (that might be you) to see -what you've done, and why you did it. +* If you get stuck, reach out on Gitter or + `discourse `__. +* When you're ready or need feedback on your code, open a pull request so that the + Matplotlib developers can give feedback and eventually include your suggested + code into the ``main`` branch. -See `linux git workflow`_ and `ipython git workflow`_ for some explanation. +.. note:: -Consider deleting your main branch -================================== + It may sound strange, but deleting your own ``main`` branch can help reduce + confusion about which branch you are on. See `deleting main on github`_ for + details. -It may sound strange, but deleting your own ``main`` branch can help reduce -confusion about which branch you are on. See `deleting main on github`_ for -details. +.. _deleting main on github: https://matthew-brett.github.io/pydagogue/gh_delete_master.html -.. _update-mirror-trunk: +.. _update-mirror-main: -Update the mirror of trunk +Update the ``main`` branch ========================== -First make sure you have done :ref:`linking-to-upstream`. +First make sure you have followed :ref:`installing_for_devs`. -From time to time you should fetch the upstream (trunk) changes from github:: +From time to time you should fetch the upstream changes from GitHub:: git fetch upstream This will pull down any commits you don't have, and set the remote branches to -point to the right commit. For example, 'trunk' is the branch referred to by -(remote/branchname) ``upstream/main`` - and if there have been commits since -you last checked, ``upstream/main`` will change after you do the fetch. +point to the right commit. .. _make-feature-branch: @@ -76,17 +65,17 @@ what the changes in the branch are for. For example ``add-ability-to-fly``, or :: - # Update the mirror of trunk + # Update the main branch git fetch upstream - # Make new feature branch starting at current trunk + # Make new feature branch starting at current main git branch my-new-feature upstream/main git checkout my-new-feature -Generally, you will want to keep your feature branches on your public github_ -fork of `Matplotlib`_. To do this, you `git push`_ this new branch up to your -github repo. Generally (if you followed the instructions in these pages, and by -default), git will have a link to your github repo, called ``origin``. You push -up to your own repo on github with:: +Generally, you will want to keep your feature branches on your public GitHub +fork of Matplotlib. To do this, you ``git push`` this new branch up to your +GitHub repo. Generally (if you followed the instructions in these pages, and by +default), git will have a link to your fork of the GitHub repo, called +``origin``. You push up to your own fork with:: git push origin my-new-feature @@ -96,7 +85,7 @@ In git >= 1.7 you can ensure that the link is correctly set by using the git push --set-upstream origin my-new-feature From now on git will know that ``my-new-feature`` is related to the -``my-new-feature`` branch in the github repo. +``my-new-feature`` branch in the GitHub repo. .. _edit-flow: @@ -117,7 +106,7 @@ In more detail -------------- #. Make some changes -#. See which files have changed with ``git status`` (see `git status`_). +#. See which files have changed with ``git status``. You'll see a listing like this one: .. code-block:: none @@ -135,90 +124,40 @@ In more detail # INSTALL no changes added to commit (use "git add" and/or "git commit -a") -#. Check what the actual changes are with ``git diff`` (`git diff`_). -#. Add any new files to version control ``git add new_file_name`` (see - `git add`_). +#. Check what the actual changes are with ``git diff``. +#. Add any new files to version control ``git add new_file_name``. #. To commit all modified files into the local copy of your repo,, do ``git commit -am 'A commit message'``. Note the ``-am`` options to ``commit``. The ``m`` flag just signals that you're going to type a - message on the command line. The ``a`` flag |emdash| you can just take on - faith |emdash| or see `why the -a flag?`_ |emdash| and the helpful use-case - description in the `tangled working copy problem`_. The `git commit`_ manual - page might also be useful. + message on the command line. The ``a`` flag — you can just take on + faith — or see `why the -a flag?`_ — and the helpful use-case + description in the `tangled working copy problem`_. The + `git commit `_ manual page might also be + useful. #. To push the changes up to your forked repo on github, do a ``git - push`` (see `git push`_). - -Ask for your changes to be reviewed or merged -============================================= + push``. -When you are ready to ask for someone to review your code and consider a merge: +.. _why the -a flag?: http://gitready.com/beginner/2009/01/18/the-staging-area.html +.. _tangled working copy problem: http://2ndscale.com/rtomayko/2008/the-thing-about-git -#. Go to the URL of your forked repo, say - ``https://github.com/your-user-name/matplotlib``. -#. Use the 'Switch Branches' dropdown menu near the top left of the page to - select the branch with your changes: - .. image:: branch_dropdown.png +Open a pull request +=================== -#. Click on the 'Pull request' button: +When you are ready to ask for someone to review your code and consider a merge, +`submit your Pull Request (PR) `_. - .. image:: pull_button.png +Enter a title for the set of changes, and some explanation of what you've done. +Say if there is anything you'd like particular attention for - like a +complicated change or some code you are not happy with. - Enter a title for the set of changes, and some explanation of what you've - done. Say if there is anything you'd like particular attention for - like a - complicated change or some code you are not happy with. - - If you don't think your request is ready to be merged, just say so in your - pull request message. This is still a good way of getting some preliminary - code review. +If you don't think your request is ready to be merged, just say so in your pull +request message and use the "Draft PR" feature of GitHub. This is a good way of +getting some preliminary code review. Some other things you might want to do ====================================== -Delete a branch on github -------------------------- - -:: - - git checkout main - # delete branch locally - git branch -D my-unwanted-branch - # delete branch on github - git push origin :my-unwanted-branch - -Note the colon ``:`` before ``my-unwanted-branch``. See also: -https://help.github.com/articles/pushing-to-a-remote/#deleting-a-remote-branch-or-tag - -Several people sharing a single repository ------------------------------------------- - -If you want to work on some stuff with other people, where you are all -committing into the same repository, or even the same branch, then just -share it via github. - -First fork Matplotlib into your account, as from :ref:`forking`. - -Then, go to your forked repository github page, say -``https://github.com/your-user-name/matplotlib`` - -Click on the 'Admin' button, and add anyone else to the repo as a -collaborator: - - .. image:: pull_button.png - -Now all those people can do:: - - git clone https://github.com/your-user-name/matplotlib.git - -Remember that links starting with ``https`` or ``git@`` are read-write, and that -``git@`` uses the ssh protocol. - -Your collaborators can then commit directly into that repo with the -usual:: - - git commit -am 'ENH - much better code' - git push origin main # pushes directly into your repo - Explore your repository ----------------------- @@ -231,59 +170,55 @@ To see a linear list of commits for this branch:: git log -You can also look at the `network graph visualizer`_ for your github -repo. +.. _rebase-on-main: -Finally the :ref:`fancy-log` ``lg`` alias will give you a reasonable text-based -graph of the repository. - -.. _rebase-on-trunk: - -Rebasing on trunk ------------------ +Rebasing on ``upstream/main`` +----------------------------- Let's say you thought of some work you'd like to do. You -:ref:`update-mirror-trunk` and :ref:`make-feature-branch` called -``cool-feature``. At this stage trunk is at some commit, let's call it E. Now -you make some new commits on your ``cool-feature`` branch, let's call them A, B, -C. Maybe your changes take a while, or you come back to them after a while. In -the meantime, trunk has progressed from commit E to commit (say) G: +:ref:`update-mirror-main` and :ref:`make-feature-branch` called +``cool-feature``. At this stage, ``main`` is at some commit, let's call it E. +Now you make some new commits on your ``cool-feature`` branch, let's call them +A, B, C. Maybe your changes take a while, or you come back to them after a +while. In the meantime, ``main`` has progressed from commit E to commit (say) G: .. code-block:: none A---B---C cool-feature / - D---E---F---G trunk + D---E---F---G main -At this stage you consider merging trunk into your feature branch, and you +At this stage you consider merging ``main`` into your feature branch, and you remember that this here page sternly advises you not to do that, because the history will get messy. Most of the time you can just ask for a review, and not -worry that trunk has got a little ahead. But sometimes, the changes in trunk -might affect your changes, and you need to harmonize them. In this situation -you may prefer to do a rebase. +worry that ``main`` has got a little ahead. But sometimes, the changes in +``main`` might affect your changes, and you need to harmonize them. In this +situation you may prefer to do a rebase. -rebase takes your changes (A, B, C) and replays them as if they had been made to -the current state of ``trunk``. In other words, in this case, it takes the -changes represented by A, B, C and replays them on top of G. After the rebase, -your history will look like this: +``rebase`` takes your changes (A, B, C) and replays them as if they had been +made to the current state of ``main``. In other words, in this case, it takes +the changes represented by A, B, C and replays them on top of G. After the +rebase, your history will look like this: .. code-block:: none A'--B'--C' cool-feature / - D---E---F---G trunk + D---E---F---G main See `rebase without tears`_ for more detail. -To do a rebase on trunk:: +.. _rebase without tears: https://matthew-brett.github.io/pydagogue/rebase_without_tears.html + +To do a rebase on ``upstream/main``:: - # Update the mirror of trunk + # Fetch changes from upstream/main git fetch upstream # go to the feature branch git checkout cool-feature # make a backup in case you mess up git branch tmp cool-feature - # rebase cool-feature onto trunk + # rebase cool-feature onto main git rebase --onto upstream/main upstream/main cool-feature In this situation, where you are already on branch ``cool-feature``, the last @@ -298,11 +233,15 @@ When all looks good you can delete your backup branch:: If it doesn't look good you may need to have a look at :ref:`recovering-from-mess-up`. -If you have made changes to files that have also changed in trunk, this may +If you have made changes to files that have also changed in ``main``, this may generate merge conflicts that you need to resolve - see the `git rebase`_ man page for some instructions at the end of the "Description" section. There is some related help on merging in the git user manual - see `resolving a merge`_. +.. _git rebase: https://git-scm.com/docs/git-rebase +.. _resolving a merge: https://schacon.github.io/git/user-manual.html#resolving-a-merge + + .. _recovering-from-mess-up: Recovering from mess-ups @@ -419,5 +358,3 @@ and the history looks now like this:: If it went wrong, recovery is again possible as explained :ref:`above `. - -.. include:: links.inc diff --git a/doc/devel/gitwash/branch_dropdown.png b/doc/devel/gitwash/branch_dropdown.png deleted file mode 100644 index 1bb7a577732c..000000000000 Binary files a/doc/devel/gitwash/branch_dropdown.png and /dev/null differ diff --git a/doc/devel/gitwash/configure_git.rst b/doc/devel/gitwash/configure_git.rst deleted file mode 100644 index eb7ce2662c93..000000000000 --- a/doc/devel/gitwash/configure_git.rst +++ /dev/null @@ -1,172 +0,0 @@ -.. highlight:: bash - -.. _configure-git: - -=============== - Configure git -=============== - -.. _git-config-basic: - -Overview -======== - -Your personal git configurations are saved in the ``.gitconfig`` file in -your home directory. - -Here is an example ``.gitconfig`` file: - -.. code-block:: none - - [user] - name = Your Name - email = you@yourdomain.example.com - - [alias] - ci = commit -a - co = checkout - st = status - stat = status - br = branch - wdiff = diff --color-words - - [core] - editor = vim - - [merge] - summary = true - -You can check what is already in your config file using the ``git config --list`` command. You can edit the ``.gitconfig`` file directly or you can use the ``git config --global`` -command.:: - - git config --global user.name "Your Name" - git config --global user.email you@yourdomain.example.com - git config --global alias.ci "commit -a" - git config --global alias.co checkout - git config --global alias.st "status -a" - git config --global alias.stat "status -a" - git config --global alias.br branch - git config --global alias.wdiff "diff --color-words" - git config --global core.editor vim - git config --global merge.summary true - -To set up on another computer, you can copy your ``~/.gitconfig`` file, -or run the commands above. - -In detail -========= - -user.name and user.email ------------------------- - -It is good practice to tell git_ who you are, for labeling any changes -you make to the code. The simplest way to do this is from the command -line:: - - git config --global user.name "Your Name" - git config --global user.email you@yourdomain.example.com - -This will write the settings into your git configuration file, which -should now contain a user section with your name and email: - -.. code-block:: none - - [user] - name = Your Name - email = you@yourdomain.example.com - -You'll need to replace ``Your Name`` and ``you@yourdomain.example.com`` -with your actual name and email address. - -Aliases -------- - -You might well benefit from some aliases to common commands. - -For example, you might well want to be able to shorten ``git checkout`` -to ``git co``. Or you may want to alias ``git diff --color-words`` -(which gives a nicely formatted output of the diff) to ``git wdiff`` - -The following ``git config --global`` commands:: - - git config --global alias.ci "commit -a" - git config --global alias.co checkout - git config --global alias.st "status -a" - git config --global alias.stat "status -a" - git config --global alias.br branch - git config --global alias.wdiff "diff --color-words" - -will create an ``alias`` section in your ``.gitconfig`` file with contents -like this: - -.. code-block:: none - - [alias] - ci = commit -a - co = checkout - st = status -a - stat = status -a - br = branch - wdiff = diff --color-words - -Editor ------- - -You may also want to make sure that your editor of choice is used :: - - git config --global core.editor vim - -Merging -------- - -To enforce summaries when doing merges (``~/.gitconfig`` file again): - -.. code-block:: none - - [merge] - log = true - -Or from the command line:: - - git config --global merge.log true - -.. _fancy-log: - -Fancy log output ----------------- - -This is a very nice alias to get a fancy log output; it should go in the -``alias`` section of your ``.gitconfig`` file: - -.. code-block:: none - - lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)[%an]%Creset' --abbrev-commit --date=relative - -You use the alias with:: - - git lg - -and it gives graph / text output something like this (but with color!): - -.. code-block:: none - - * 6d8e1ee - (HEAD, origin/my-fancy-feature, my-fancy-feature) NF - a fancy file (45 minutes ago) [Matthew Brett] - * d304a73 - (origin/placeholder, placeholder) Merge pull request #48 from hhuuggoo/master (2 weeks ago) [Jonathan Terhorst] - |\ - | * 4aff2a8 - fixed bug 35, and added a test in test_bugfixes (2 weeks ago) [Hugo] - |/ - * a7ff2e5 - Added notes on discussion/proposal made during Data Array Summit. (2 weeks ago) [Corran Webster] - * 68f6752 - Initial implementation of AxisIndexer - uses 'index_by' which needs to be changed to a call on an Axes object - this is all very sketchy right now. (2 weeks ago) [Corr - * 376adbd - Merge pull request #46 from terhorst/master (2 weeks ago) [Jonathan Terhorst] - |\ - | * b605216 - updated joshu example to current api (3 weeks ago) [Jonathan Terhorst] - | * 2e991e8 - add testing for outer ufunc (3 weeks ago) [Jonathan Terhorst] - | * 7beda5a - prevent axis from throwing an exception if testing equality with non-axis object (3 weeks ago) [Jonathan Terhorst] - | * 65af65e - convert unit testing code to assertions (3 weeks ago) [Jonathan Terhorst] - | * 956fbab - Merge remote-tracking branch 'upstream/master' (3 weeks ago) [Jonathan Terhorst] - | |\ - | |/ - -Thanks to Yury V. Zaytsev for posting it. - -.. include:: links.inc diff --git a/doc/devel/gitwash/dot2_dot3.rst b/doc/devel/gitwash/dot2_dot3.rst deleted file mode 100644 index 30852b5ad387..000000000000 --- a/doc/devel/gitwash/dot2_dot3.rst +++ /dev/null @@ -1,28 +0,0 @@ -.. _dot2-dot3: - -======================================== - Two and three dots in difference specs -======================================== - -Thanks to Yarik Halchenko for this explanation. - -Imagine a series of commits A, B, C, D... Imagine that there are two -branches, *topic* and *main*. You branched *topic* off *main* when -*main* was at commit 'E'. The graph of the commits looks like this:: - - - A---B---C topic - / - D---E---F---G main - -Then:: - - git diff main..topic - -will output the difference from G to C (i.e. with effects of F and G), -while:: - - git diff main...topic - -would output just differences in the topic branch (i.e. only A, B, and -C). diff --git a/doc/devel/gitwash/following_latest.rst b/doc/devel/gitwash/following_latest.rst deleted file mode 100644 index 5c90f5b84446..000000000000 --- a/doc/devel/gitwash/following_latest.rst +++ /dev/null @@ -1,38 +0,0 @@ -.. highlight:: bash - -.. _following-latest: - -============================= - Following the latest source -============================= - -These are the instructions if you just want to follow the latest -*Matplotlib* source, but you don't need to do any development for now. - -The steps are: - -* :ref:`install-git` -* get local copy of the `Matplotlib github`_ git repository -* update local copy from time to time - -Get the local copy of the code -============================== - -From the command line:: - - git clone https://github.com/matplotlib/matplotlib.git - -You now have a copy of the code tree in the new ``matplotlib`` directory. - -Updating the code -================= - -From time to time you may want to pull down the latest code. Do this with:: - - cd matplotlib - git pull - -The tree in ``matplotlib`` will now have the latest changes from the initial -repository. - -.. include:: links.inc diff --git a/doc/devel/gitwash/forking_button.png b/doc/devel/gitwash/forking_button.png deleted file mode 100644 index d0e04134d4d0..000000000000 Binary files a/doc/devel/gitwash/forking_button.png and /dev/null differ diff --git a/doc/devel/gitwash/forking_hell.rst b/doc/devel/gitwash/forking_hell.rst deleted file mode 100644 index b79e13400a62..000000000000 --- a/doc/devel/gitwash/forking_hell.rst +++ /dev/null @@ -1,34 +0,0 @@ -.. highlight:: bash - -.. _forking: - -====================================================== -Making your own copy (fork) of Matplotlib -====================================================== - -You need to do this only once. The instructions here are very similar -to the instructions at https://help.github.com/forking/ |emdash| please see -that page for more detail. We're repeating some of it here just to give the -specifics for the `Matplotlib`_ project, and to suggest some default names. - -Set up and configure a github account -===================================== - -If you don't have a github account, go to the github page, and make one. - -You then need to configure your account to allow write access |emdash| see -the ``Generating SSH keys`` help on `github help`_. - -Create your own forked copy of `Matplotlib`_ -====================================================== - -#. Log into your github account. -#. Go to the `Matplotlib`_ github home at `Matplotlib github`_. -#. Click on the *fork* button: - - .. image:: forking_button.png - - Now, after a short pause, you should find yourself at the home page for - your own forked copy of `Matplotlib`_. - -.. include:: links.inc diff --git a/doc/devel/gitwash/git_development.rst b/doc/devel/gitwash/git_development.rst deleted file mode 100644 index c5b910d86342..000000000000 --- a/doc/devel/gitwash/git_development.rst +++ /dev/null @@ -1,16 +0,0 @@ -.. _git-development: - -===================== - Git for development -===================== - -Contents: - -.. toctree:: - :maxdepth: 2 - - forking_hell - set_up_fork - configure_git - development_workflow - maintainer_workflow diff --git a/doc/devel/gitwash/git_install.rst b/doc/devel/gitwash/git_install.rst deleted file mode 100644 index 66eca8c29bde..000000000000 --- a/doc/devel/gitwash/git_install.rst +++ /dev/null @@ -1,28 +0,0 @@ -.. highlight:: bash - -.. _install-git: - -============= - Install git -============= - -Overview -======== - -================ ============= -Debian / Ubuntu ``sudo apt-get install git`` -Fedora ``sudo yum install git`` -Windows Download and install msysGit_ -OS X Use the git-osx-installer_ -================ ============= - -In detail -========= - -See the git page for the most recent information. - -Have a look at the github install help pages available from `github help`_ - -There are good instructions here: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git - -.. include:: links.inc diff --git a/doc/devel/gitwash/git_intro.rst b/doc/devel/gitwash/git_intro.rst deleted file mode 100644 index 1f89b7e9fb51..000000000000 --- a/doc/devel/gitwash/git_intro.rst +++ /dev/null @@ -1,20 +0,0 @@ -.. highlight:: bash - -============== - Introduction -============== - -These pages describe a git_ and github_ workflow for the `Matplotlib`_ -project. - -There are several different workflows here, for different ways of -working with *Matplotlib*. - -This is not a comprehensive git reference, it's just a workflow for our -own project. It's tailored to the github hosting service. You may well -find better or quicker ways of getting stuff done with git, but these -should get you started. - -For general resources for learning git, see :ref:`git-resources`. - -.. include:: links.inc diff --git a/doc/devel/gitwash/git_links.inc b/doc/devel/gitwash/git_links.inc deleted file mode 100644 index 67ddc4dcb5a6..000000000000 --- a/doc/devel/gitwash/git_links.inc +++ /dev/null @@ -1,59 +0,0 @@ -.. This (-*- rst -*-) format file contains commonly used link targets - and name substitutions. It may be included in many files, - therefore it should only contain link targets and name - substitutions. Try grepping for "^\.\. _" to find plausible - candidates for this list. - -.. NOTE: reST targets are - __not_case_sensitive__, so only one target definition is needed for - nipy, NIPY, Nipy, etc... - -.. git stuff -.. _git: https://git-scm.com/ -.. _github: https://github.com -.. _github help: https://help.github.com -.. _msysgit: https://git-scm.com/download/win -.. _git-osx-installer: https://git-scm.com/download/mac -.. _subversion: https://subversion.apache.org/ -.. _git cheat sheet: https://help.github.com/git-cheat-sheets/ -.. _pro git book: https://git-scm.com/book/en/v2 -.. _git svn crash course: https://git-scm.com/course/svn.html -.. _network graph visualizer: https://github.com/blog/39-say-hello-to-the-network-graph-visualizer -.. _git user manual: https://schacon.github.io/git/user-manual.html -.. _git tutorial: https://schacon.github.io/git/gittutorial.html -.. _git community book: https://git-scm.com/book/en/v2 -.. _git ready: http://gitready.com/ -.. _Fernando's git page: http://www.fperez.org/py4science/git.html -.. _git magic: http://www-cs-students.stanford.edu/~blynn/gitmagic/index.html -.. _git concepts: https://www.sbf5.com/~cduan/technical/git/ -.. _git clone: https://schacon.github.io/git/git-clone.html -.. _git checkout: https://schacon.github.io/git/git-checkout.html -.. _git commit: https://schacon.github.io/git/git-commit.html -.. _git push: https://schacon.github.io/git/git-push.html -.. _git pull: https://schacon.github.io/git/git-pull.html -.. _git add: https://schacon.github.io/git/git-add.html -.. _git status: https://schacon.github.io/git/git-status.html -.. _git diff: https://schacon.github.io/git/git-diff.html -.. _git log: https://schacon.github.io/git/git-log.html -.. _git branch: https://schacon.github.io/git/git-branch.html -.. _git remote: https://schacon.github.io/git/git-remote.html -.. _git rebase: https://schacon.github.io/git/git-rebase.html -.. _git config: https://schacon.github.io/git/git-config.html -.. _why the -a flag?: http://gitready.com/beginner/2009/01/18/the-staging-area.html -.. _git staging area: http://gitready.com/beginner/2009/01/18/the-staging-area.html -.. _tangled working copy problem: http://2ndscale.com/rtomayko/2008/the-thing-about-git -.. _git management: https://web.archive.org/web/20090224195437/http://kerneltrap.org/Linux/Git_Management -.. _linux git workflow: https://www.mail-archive.com/dri-devel@lists.sourceforge.net/msg39091.html -.. _git parable: http://tom.preston-werner.com/2009/05/19/the-git-parable.html -.. _git foundation: https://matthew-brett.github.io/pydagogue/foundation.html -.. _deleting main on github: https://matthew-brett.github.io/pydagogue/gh_delete_master.html -.. _rebase without tears: https://matthew-brett.github.io/pydagogue/rebase_without_tears.html -.. _resolving a merge: https://schacon.github.io/git/user-manual.html#resolving-a-merge -.. _ipython git workflow: https://mail.python.org/pipermail/ipython-dev/2010-October/005632.html - -.. other stuff -.. _python: https://www.python.org - -.. |emdash| unicode:: U+02014 - -.. vim: ft=rst diff --git a/doc/devel/gitwash/git_resources.rst b/doc/devel/gitwash/git_resources.rst deleted file mode 100644 index 2787a575cc43..000000000000 --- a/doc/devel/gitwash/git_resources.rst +++ /dev/null @@ -1,59 +0,0 @@ -.. highlight:: bash - -.. _git-resources: - -============= -git resources -============= - -Tutorials and summaries -======================= - -* `github help`_ has an excellent series of how-to guides. -* The `pro git book`_ is a good in-depth book on git. -* A `git cheat sheet`_ is a page giving summaries of common commands. -* The `git user manual`_ -* The `git tutorial`_ -* The `git community book`_ -* `git ready`_ |emdash| a nice series of tutorials -* `git magic`_ |emdash| extended introduction with intermediate detail -* The `git parable`_ is an easy read explaining the concepts behind git. -* `git foundation`_ expands on the `git parable`_. -* Fernando Perez' git page |emdash| `Fernando's git page`_ |emdash| many - links and tips -* A good but technical page on `git concepts`_ -* `git svn crash course`_: git for those of us used to subversion_ - -Advanced git workflow -===================== - -There are many ways of working with git; here are some posts on the -rules of thumb that other projects have come up with: - -* Linus Torvalds on `git management`_ -* Linus Torvalds on `linux git workflow`_ . Summary; use the git tools - to make the history of your edits as clean as possible; merge from - upstream edits as little as possible in branches where you are doing - active development. - -Manual pages online -=================== - -You can get these on your own machine with (e.g) ``git help push`` or -(same thing) ``git push --help``, but, for convenience, here are the -online manual pages for some common commands: - -* `git add`_ -* `git branch`_ -* `git checkout`_ -* `git clone`_ -* `git commit`_ -* `git config`_ -* `git diff`_ -* `git log`_ -* `git pull`_ -* `git push`_ -* `git remote`_ -* `git status`_ - -.. include:: links.inc diff --git a/doc/devel/gitwash/index.rst b/doc/devel/gitwash/index.rst deleted file mode 100644 index 9ee965d626ff..000000000000 --- a/doc/devel/gitwash/index.rst +++ /dev/null @@ -1,19 +0,0 @@ -.. _using-git: - -Working with *Matplotlib* source code -================================================ - -Contents: - -.. toctree:: - :maxdepth: 2 - - git_intro - git_install - following_latest - patching - git_development - git_resources - dot2_dot3 - - diff --git a/doc/devel/gitwash/known_projects.inc b/doc/devel/gitwash/known_projects.inc deleted file mode 100644 index 710abe08e477..000000000000 --- a/doc/devel/gitwash/known_projects.inc +++ /dev/null @@ -1,41 +0,0 @@ -.. Known projects - -.. PROJECTNAME placeholders -.. _PROJECTNAME: http://nipy.org -.. _`PROJECTNAME github`: https://github.com/nipy -.. _`PROJECTNAME mailing list`: https://mail.python.org/mailman/listinfo/neuroimaging - -.. numpy -.. _numpy: http://www.numpy.org -.. _`numpy github`: https://github.com/numpy/numpy -.. _`numpy mailing list`: https://mail.scipy.org/mailman/listinfo/numpy-discussion - -.. scipy -.. _scipy: https://www.scipy.org -.. _`scipy github`: https://github.com/scipy/scipy -.. _`scipy mailing list`: https://mail.scipy.org/mailman/listinfo/scipy-dev - -.. nipy -.. _nipy: http://nipy.org/nipy/ -.. _`nipy github`: https://github.com/nipy/nipy -.. _`nipy mailing list`: https://mail.python.org/mailman/listinfo/neuroimaging - -.. ipython -.. _ipython: https://ipython.org -.. _`ipython github`: https://github.com/ipython/ipython -.. _`ipython mailing list`: https://mail.scipy.org/mailman/listinfo/IPython-dev - -.. dipy -.. _dipy: http://nipy.org/dipy/ -.. _`dipy github`: https://github.com/Garyfallidis/dipy -.. _`dipy mailing list`: https://mail.python.org/mailman/listinfo/neuroimaging - -.. nibabel -.. _nibabel: http://nipy.org/nibabel/ -.. _`nibabel github`: https://github.com/nipy/nibabel -.. _`nibabel mailing list`: https://mail.python.org/mailman/listinfo/neuroimaging - -.. marsbar -.. _marsbar: http://marsbar.sourceforge.net -.. _`marsbar github`: https://github.com/matthew-brett/marsbar -.. _`MarsBaR mailing list`: https://lists.sourceforge.net/lists/listinfo/marsbar-users diff --git a/doc/devel/gitwash/links.inc b/doc/devel/gitwash/links.inc deleted file mode 100644 index 20f4dcfffd4a..000000000000 --- a/doc/devel/gitwash/links.inc +++ /dev/null @@ -1,4 +0,0 @@ -.. compiling links file -.. include:: known_projects.inc -.. include:: this_project.inc -.. include:: git_links.inc diff --git a/doc/devel/gitwash/patching.rst b/doc/devel/gitwash/patching.rst deleted file mode 100644 index aeea8c5394ac..000000000000 --- a/doc/devel/gitwash/patching.rst +++ /dev/null @@ -1,138 +0,0 @@ -.. highlight:: bash - -================ - Making a patch -================ - -You've discovered a bug or something else you want to change -in `Matplotlib`_ .. |emdash| excellent! - -You've worked out a way to fix it |emdash| even better! - -You want to tell us about it |emdash| best of all! - -The easiest way is to make a *patch* or set of patches. Here -we explain how. Making a patch is the simplest and quickest, -but if you're going to be doing anything more than simple -quick things, please consider following the -:ref:`git-development` model instead. - -.. _making-patches: - -Making patches -============== - -Overview --------- - -:: - - # tell git who you are - git config --global user.email you@yourdomain.example.com - git config --global user.name "Your Name Comes Here" - # get the repository if you don't have it - git clone https://github.com/matplotlib/matplotlib.git - # make a branch for your patching - cd matplotlib - git branch the-fix-im-thinking-of - git checkout the-fix-im-thinking-of - # hack, hack, hack - # Tell git about any new files you've made - git add somewhere/tests/test_my_bug.py - # commit work in progress as you go - git commit -am 'BF - added tests for Funny bug' - # hack hack, hack - git commit -am 'BF - added fix for Funny bug' - # make the patch files - git format-patch -M -C main - -Then, send the generated patch files to the `Matplotlib -mailing list`_ |emdash| where we will thank you warmly. - -In detail ---------- - -#. Tell git who you are so it can label the commits you've - made:: - - git config --global user.email you@yourdomain.example.com - git config --global user.name "Your Name Comes Here" - -#. If you don't already have one, clone a copy of the - `Matplotlib`_ repository:: - - git clone https://github.com/matplotlib/matplotlib.git - cd matplotlib - -#. Make a 'feature branch'. This will be where you work on - your bug fix. It's nice and safe and leaves you with - access to an unmodified copy of the code in the main - branch:: - - git branch the-fix-im-thinking-of - git checkout the-fix-im-thinking-of - -#. Do some edits, and commit them as you go:: - - # hack, hack, hack - # Tell git about any new files you've made - git add somewhere/tests/test_my_bug.py - # commit work in progress as you go - git commit -am 'BF - added tests for Funny bug' - # hack hack, hack - git commit -am 'BF - added fix for Funny bug' - - Note the ``-am`` options to ``commit``. The ``m`` flag just - signals that you're going to type a message on the command - line. The ``a`` flag |emdash| you can just take on faith |emdash| - or see `why the -a flag?`_. - -#. When you have finished, check you have committed all your - changes:: - - git status - -#. Finally, make your commits into patches. You want all the - commits since you branched from the ``main`` branch:: - - git format-patch -M -C main - - You will now have several files named for the commits: - - .. code-block:: none - - 0001-BF-added-tests-for-Funny-bug.patch - 0002-BF-added-fix-for-Funny-bug.patch - - Send these files to the `Matplotlib mailing list`_. - -When you are done, to switch back to the main copy of the -code, just return to the ``main`` branch:: - - git checkout main - -Moving from patching to development -=================================== - -If you find you have done some patches, and you have one or -more feature branches, you will probably want to switch to -development mode. You can do this with the repository you -have. - -Fork the `Matplotlib`_ repository on github |emdash| :ref:`forking`. -Then:: - - # checkout and refresh main branch from main repo - git checkout main - git pull origin main - # rename pointer to main repository to 'upstream' - git remote rename origin upstream - # point your repo to default read / write to your fork on github - git remote add origin git@github.com:your-user-name/matplotlib.git - # push up any branches you've made and want to keep - git push origin the-fix-im-thinking-of - -Then you can, if you want, follow the -:ref:`development-workflow`. - -.. include:: links.inc diff --git a/doc/devel/gitwash/pull_button.png b/doc/devel/gitwash/pull_button.png deleted file mode 100644 index e5031681b97b..000000000000 Binary files a/doc/devel/gitwash/pull_button.png and /dev/null differ diff --git a/doc/devel/gitwash/set_up_fork.rst b/doc/devel/gitwash/set_up_fork.rst deleted file mode 100644 index cfbd00dca63f..000000000000 --- a/doc/devel/gitwash/set_up_fork.rst +++ /dev/null @@ -1,68 +0,0 @@ -.. highlight:: bash - -.. _set-up-fork: - -================== - Set up your fork -================== - -First you follow the instructions for :ref:`forking`. - -Overview -======== - -:: - - git clone https://github.com/your-user-name/matplotlib.git - cd matplotlib - git remote add upstream https://github.com/matplotlib/matplotlib.git - -In detail -========= - -Clone your fork ---------------- - -#. Clone your fork to the local computer with ``git clone - https://github.com/your-user-name/matplotlib.git`` -#. Investigate. Change directory to your new repo: ``cd matplotlib``. Then - ``git branch -a`` to show you all branches. You'll get something - like: - - .. code-block:: none - - * main - remotes/origin/main - - This tells you that you are currently on the ``main`` branch, and - that you also have a ``remote`` connection to ``origin/main``. - What remote repository is ``remote/origin``? Try ``git remote -v`` to - see the URLs for the remote. They will point to your github fork. - - Now you want to connect to the upstream `Matplotlib github`_ repository, so - you can merge in changes from trunk. - -.. _linking-to-upstream: - -Linking your repository to the upstream repo --------------------------------------------- - -:: - - cd matplotlib - git remote add upstream https://github.com/matplotlib/matplotlib.git - -``upstream`` here is just the arbitrary name we're using to refer to the -main `Matplotlib`_ repository at `Matplotlib github`_. - -Just for your own satisfaction, show yourself that you now have a new -'remote', with ``git remote -v show``, giving you something like: - -.. code-block:: none - - upstream https://github.com/matplotlib/matplotlib.git (fetch) - upstream https://github.com/matplotlib/matplotlib.git (push) - origin https://github.com/your-user-name/matplotlib.git (fetch) - origin https://github.com/your-user-name/matplotlib.git (push) - -.. include:: links.inc diff --git a/doc/devel/gitwash/this_project.inc b/doc/devel/gitwash/this_project.inc deleted file mode 100644 index e8863d5f78f0..000000000000 --- a/doc/devel/gitwash/this_project.inc +++ /dev/null @@ -1,5 +0,0 @@ -.. Matplotlib -.. _`Matplotlib`: http://matplotlib.org -.. _`Matplotlib github`: https://github.com/matplotlib/matplotlib - -.. _`Matplotlib mailing list`: https://mail.python.org/mailman/listinfo/matplotlib-devel diff --git a/doc/devel/index.rst b/doc/devel/index.rst index 462205ee2271..66787b62736e 100644 --- a/doc/devel/index.rst +++ b/doc/devel/index.rst @@ -57,14 +57,15 @@ process or how to fix something feel free to ask on `gitter contributing.rst triage.rst development_setup.rst + development_workflow.rst testing.rst documenting_mpl.rst style_guide.rst - gitwash/index.rst coding_guide.rst release_guide.rst dependencies.rst min_dep_policy.rst + maintainer_workflow.rst MEP/index .. toctree:: diff --git a/doc/devel/gitwash/maintainer_workflow.rst b/doc/devel/maintainer_workflow.rst similarity index 96% rename from doc/devel/gitwash/maintainer_workflow.rst rename to doc/devel/maintainer_workflow.rst index 9a572e311168..f11375e26d1b 100644 --- a/doc/devel/gitwash/maintainer_workflow.rst +++ b/doc/devel/maintainer_workflow.rst @@ -6,7 +6,7 @@ Maintainer workflow ################### -This page is for maintainers |emdash| those of us who merge our own or other +This page is for maintainers — those of us who merge our own or other peoples' changes into the upstream repository. Being as how you're a maintainer, you are completely on top of the basic stuff @@ -94,5 +94,3 @@ Push to trunk This pushes the ``my-new-feature`` branch in this repository to the ``main`` branch in the ``upstream-rw`` repository. - -.. include:: links.inc