Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0849036

Browse files
authored
Merge pull request #26201 from melissawm/add-codespaces-docs
DOC: Add documentation on codespaces usage
2 parents f9229b5 + 34c7e52 commit 0849036

File tree

3 files changed

+90
-20
lines changed

3 files changed

+90
-20
lines changed

.devcontainer/devcontainer.json

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
{
32
"hostRequirements": {
43
"memory": "8gb",
@@ -13,6 +12,12 @@
1312
},
1413
"onCreateCommand": ".devcontainer/setup.sh",
1514
"postCreateCommand": "",
15+
"forwardPorts": [6080],
16+
"portsAttributes": {
17+
"6080": {
18+
"label": "desktop"
19+
}
20+
},
1621
"customizations": {
1722
"vscode": {
1823
"extensions": [
@@ -22,11 +27,12 @@
2227
"ms-vscode.live-server"
2328
],
2429
"settings": {}
30+
},
31+
"codespaces": {
32+
"openFiles": [
33+
"README.md",
34+
"doc/devel/codespaces.md"
35+
]
2536
}
26-
},
27-
"portsAttributes": {
28-
"6080": {
29-
"label": "desktop"
30-
}
31-
}
37+
}
3238
}

doc/devel/codespaces.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Contributing to Matplotlib using GitHub codespaces
2+
3+
* For a general overview of contributing to Matplotlib, see https://matplotlib.org/devdocs/devel/index.html
4+
5+
* For instructions on how to submit Pull Requests using GitHub codespaces, see https://matplotlib.org/devdocs/devel/contribute.html#contributing-code
6+
7+
* For instructions on running tests to verify your changes, see https://matplotlib.org/devdocs/devel/testing.html
8+
9+
* For instructions on building the Matplotlib documentation, see https://matplotlib.org/devdocs/devel/document.html#documenting-matplotlib

doc/devel/contribute.rst

Lines changed: 68 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,13 @@ How to contribute
221221

222222
The preferred way to contribute to Matplotlib is to fork the `main
223223
repository <https://github.com/matplotlib/matplotlib/>`__ on GitHub,
224-
then submit a "pull request" (PR).
224+
then submit a "pull request" (PR). You can do this by cloning a copy of the
225+
Maplotlib repository to your own computer, or alternatively using
226+
`GitHub Codespaces <https://docs.github.com/codespaces>`_, a cloud-based
227+
in-browser development environment that comes with the appropriated setup to
228+
contribute to Matplotlib.
225229

226-
A brief overview is:
230+
A brief overview of the workflow is as follows.
227231

228232
1. `Create an account <https://github.com/join>`_ on GitHub if you do not
229233
already have one.
@@ -232,35 +236,86 @@ A brief overview is:
232236
click on the 'Fork' button near the top of the page. This creates a copy of
233237
the code under your account on the GitHub server.
234238

235-
3. Clone this copy to your local disk::
239+
.. tab-set::
236240

237-
git clone https://github.com/<YOUR GITHUB USERNAME>/matplotlib.git
241+
.. tab-item:: Local development
238242

239-
4. Enter the directory and install the local version of Matplotlib.
240-
See :ref:`installing_for_devs` for instructions
243+
3. Clone this copy to your local disk::
244+
245+
git clone https://github.com/<YOUR GITHUB USERNAME>/matplotlib.git
246+
247+
.. tab-item:: Using GitHub Codespaces
248+
249+
3. Check out the Matplotlib repository and activate your development
250+
environment:
251+
252+
* Open codespaces on your fork by clicking on the green "Code" button
253+
on the GitHub web interface and selecting the "Codespaces" tab.
254+
* Next, click on "Open codespaces on <your branch name>". You will be
255+
able to change branches later, so you can select the default
256+
``main`` branch.
257+
* After the codespace is created, you will be taken to a new browser
258+
tab where you can use the terminal to activate a pre-defined conda
259+
environment called ``mpl-dev``::
260+
261+
conda activate mpl-dev
262+
263+
264+
265+
4. Install the local version of Matplotlib with::
266+
267+
python -m pip install -e .
268+
269+
See :ref:`installing_for_devs` for detailed instructions.
241270

242271
5. Create a branch to hold your changes::
243272

244-
git checkout -b my-feature origin/main
273+
git checkout -b my-feature origin/main
245274

246275
and start making changes. Never work in the ``main`` branch!
247276

248-
6. Work on this copy, on your computer, using Git to do the version control.
249-
When you're done editing e.g., ``lib/matplotlib/collections.py``, do::
277+
6. Work on this task using Git to do the version control. Codespaces persist for
278+
some time (check the `documentation for details
279+
<https://docs.github.com/codespaces/getting-started/the-codespace-lifecycle>`_)
280+
and can be managed on https://github.com/codespaces. When you're done editing
281+
e.g., ``lib/matplotlib/collections.py``, do::
250282

251-
git add lib/matplotlib/collections.py
252-
git commit
283+
git add lib/matplotlib/collections.py
284+
git commit
253285

254-
to record your changes in Git, then push them to GitHub with::
286+
to record your changes in Git, then push them to your GitHub fork with::
255287

256-
git push -u origin my-feature
288+
git push -u origin my-feature
257289

258290
Finally, go to the web page of your fork of the Matplotlib repo, and click
259291
'Pull request' to send your changes to the maintainers for review.
260292

261293
For more detailed instructions on how to set up Matplotlib for development and
262294
best practices for contribution, see :ref:`installing_for_devs`.
263295

296+
GitHub Codespaces workflows
297+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
298+
299+
* If you need to open a GUI window with Matplotlib output on Codespaces, our
300+
configuration includes a `light-weight Fluxbox-based desktop
301+
<https://github.com/devcontainers/features/tree/main/src/desktop-lite>`_.
302+
You can use it by connecting to this desktop via your web browser. To do this:
303+
304+
1. Press ``F1`` or ``Ctrl/Cmd+Shift+P`` and select
305+
``Ports: Focus on Ports View`` in the VSCode session to bring it into
306+
focus. Open the ports view in your tool, select the ``noVNC`` port, and
307+
click the Globe icon.
308+
2. In the browser that appears, click the Connect button and enter the desktop
309+
password (``vscode`` by default).
310+
311+
Check the `GitHub instructions
312+
<https://github.com/devcontainers/features/tree/main/src/desktop-lite#connecting-to-the-desktop>`_
313+
for more details on connecting to the desktop.
314+
315+
* If you also built the documentation pages, you can view them using Codespaces.
316+
Use the "Extensions" icon in the activity bar to install the "Live Server"
317+
extension. Locate the ``doc/build/html`` folder in the Explorer, right click
318+
the file you want to open and select "Open with Live Server."
264319

265320
.. _contributing_documentation:
266321

0 commit comments

Comments
 (0)