-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdevelop.html
600 lines (548 loc) · 34.2 KB
/
develop.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Developer guide — Fatiando 0.5</title>
<link rel="stylesheet" href="_static/basic.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/gallery.css" type="text/css" />
<link rel="stylesheet" href="_static/bootswatch-3.2.0/flatly/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="_static/bootstrap-sphinx.css" type="text/css" />
<link rel="stylesheet" href="_static/style.css" type="text/css" />
<link rel="stylesheet" href="_static/font-awesome/css/font-awesome.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: 'ac692aa892ddbb386f6a76d0f429099587eb2b37',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="_static/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="_static/js/jquery-fix.js"></script>
<script type="text/javascript" src="_static/bootstrap-3.2.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="_static/bootstrap-sphinx.js"></script>
<link rel="shortcut icon" href="_static/favicon.ico"/>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="top" title="Fatiando 0.5" href="index.html" />
<link rel="next" title="Contributors" href="contributors.html" />
<link rel="prev" title="Optimization routines (fatiando.inversion.optimization)" href="api/inversion.optimization.html" />
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- Plausible analytics for anonymous usage statistics -->
<script defer data-domain="legacy.fatiando.org" src="https://plausible.io/js/plausible.js"></script>
</head>
<body role="document">
<div class="deprecation-banner" id="deprecationBanner">
<div class="container">
<p>
The <code>fatiando</code> package has been deprecated. Please check out
the new tools in the Fatiando a Terra website:
<a href="https://www.fatiando.org">www.fatiando.org</a>
</p>
</div>
</div>
<div id="navbar" class="navbar navbar-default navbar-default ">
<div class="container">
<div class="navbar-header">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html"><img src="_static/fatiando-logo.png">
fatiando</a>
<span class="navbar-text navbar-version pull-left"><b>0.5</b></span>
</div>
<div class="collapse navbar-collapse nav-collapse">
<ul class="nav navbar-nav">
<li><a href="install.html">Install</a></li>
<li><a href="gallery/index.html">Gallery</a></li>
<li><a href="api/fatiando.html">API</a></li>
<li><a href="docs.html">Docs</a></li>
<li><a href="#">Contribute</a></li>
<li class="dropdown globaltoc-container">
<a role="button"
id="dLabelGlobalToc"
data-toggle="dropdown"
data-target="#"
href="index.html">Site <b class="caret"></b></a>
<ul class="dropdown-menu globaltoc"
role="menu"
aria-labelledby="dLabelGlobalToc"></ul>
</li>
</ul>
<form class="navbar-form navbar-right" action="search.html" method="get">
<div class="form-group">
<input type="text" name="q" class="form-control" placeholder="Search" />
</div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-3">
<div id="sidebar" class="bs-sidenav" role="complementary"><ul>
<li><a class="reference internal" href="#">Developer guide</a><ul>
<li><a class="reference internal" href="#getting-started">Getting started</a></li>
<li><a class="reference internal" href="#setting-up">Setting up</a></li>
<li><a class="reference internal" href="#testing">Testing</a></li>
<li><a class="reference internal" href="#adding-new-code-fixes-docs">Adding new code/fixes/docs</a></li>
<li><a class="reference internal" href="#code-style">Code Style</a></li>
<li><a class="reference internal" href="#documentation">Documentation</a></li>
<li><a class="reference internal" href="#pull-requests">Pull Requests</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="col-md-9">
<div class="section" id="developer-guide">
<span id="develop"></span><h1>Developer guide<a class="headerlink" href="#developer-guide" title="Permalink to this headline">¶</a></h1>
<div class="section" id="getting-started">
<h2>Getting started<a class="headerlink" href="#getting-started" title="Permalink to this headline">¶</a></h2>
<p>The first thing you’ll need is a <a class="reference external" href="https://github.com/">Github</a> account.
You can sign up for free.
If you are an academic or student,
<a class="reference external" href="https://education.github.com/">request a free pro-account</a> to get access to
private repositories.</p>
<div class="admonition tip">
<p class="first admonition-title">Tip</p>
<p class="last">The easiest way to contribute is to
<a class="reference external" href="https://github.com/fatiando/fatiando/issues">submit issues and bug reports</a>.
Feature requests, typo fixes, suggestions for the documentation, it’s all
welcome!</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If you are new to <strong>version control</strong> (or don’t know what that means),
start with the <a class="reference external" href="http://software-carpentry.org/">Software Carpentry lessons on version control with Git</a>.
After you’ve gone through those, the
Github <a class="reference external" href="https://help.github.com/">help page</a>
and <a class="reference external" href="https://guides.github.com/">guides</a>
are great resources for finding your way around the quirks of git and
Github.</p>
</div>
<p>All of the “official” code for Fatiando lives in the
<a class="reference external" href="https://github.com/fatiando/fatiando">fatiando/fatiando repository</a>
(the first <code class="docutils literal"><span class="pre">fatiando</span></code> refers to the
<a class="reference external" href="https://github.com/fatiando">fatiando Github account</a>).
The <em>master</em> branch of the repository contains the latest code that is
<strong>stable</strong> (should have tested and working code).
Code that is in <a class="reference external" href="https://github.com/fatiando/fatiando/branches">other branches</a>
are things that are under development by the
<a class="reference external" href="https://github.com/fatiando/fatiando/graphs/contributors">main developers</a>.</p>
<p>To contribute some code/fix/documentation, start by forking
<a class="reference external" href="https://github.com/fatiando/fatiando/">fatiando/fatiando</a>
(click the “Fork” button).
This will grab a complete copy of the code repository and add it to your
account.
This “fork” is isolated from the main repository, so you don’t have to worry
about “breaking” anything.
Go nuts!
If you break your fork beyond repair you can always delete it and make a new
fork.
Beware that you will lose <strong>everything</strong> in your fork if you delete it.</p>
<p>Once you have your fork, clone a copy to your computer:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">clone</span> <span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">github</span><span class="o">.</span><span class="n">com</span><span class="o">/</span><span class="n">USERNAME</span><span class="o">/</span><span class="n">fatiando</span><span class="o">.</span><span class="n">git</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Not sure what to work on? Have a look at the
<a class="reference external" href="https://github.com/fatiando/fatiando/issues">open issues</a>
and pick one that you find interesting.
<strong>Please leave a comment on the issue if you are going to work on it</strong>.
This helps us keep track of who is doing what and avoid duplicated work.
We are trying to curate a
<a class="reference external" href="https://github.com/fatiando/fatiando/issues?q=is%3Aopen+is%3Aissue+label%3A%22low-hanging+fruit%22">list of “low-hanging fruit”</a>
that are suitable for new-comers.
Note that “low-hanging” does not necessarily mean trivial,
but that it doesn’t require extensive knowledge of the project.
<strong>Helping by writing/reviewing/improving the documentation is VERY
appreciated</strong>. We welcome even the simplest typo fix!</p>
</div>
</div>
<div class="section" id="setting-up">
<h2>Setting up<a class="headerlink" href="#setting-up" title="Permalink to this headline">¶</a></h2>
<p>You will need some extra dependencies installed for development.
See files <code class="docutils literal"><span class="pre">ci/requirements-conda.txt</span></code> and <code class="docutils literal"><span class="pre">ci/requirements-pip.txt</span></code>.
If you are using Anaconda (and you should),
the repository provides an <code class="docutils literal"><span class="pre">environment.yml</span></code> file that specifies a <code class="docutils literal"><span class="pre">conda</span></code>
virtual environment with all packages that you’ll need.
This will keep the Fatiando development related installation from you main
Python.
The main advantage is that you can make changes to Fatiando and test them while
still using a stable release (like 0.4) for your main work.
Otherwise, changes to the code would likely break everything else you’re
working on.</p>
<p>Run the following from the repository base directory to create the environment
using the specification in the <code class="docutils literal"><span class="pre">environment.yml</span></code> file:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">conda</span> <span class="n">env</span> <span class="n">create</span>
</pre></div>
</div>
<p>Now, whenever you want to run code using the <code class="docutils literal"><span class="pre">fatiando-dev</span></code> environment we
just created, you must run this first to activate the environment:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">source</span> <span class="n">activate</span> <span class="n">fatiando</span><span class="o">-</span><span class="n">dev</span>
</pre></div>
</div>
<p>or on Windows:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">activate</span> <span class="n">fatiando</span><span class="o">-</span><span class="n">dev</span>
</pre></div>
</div>
<p>Optionally, you can use <a class="reference external" href="http://www.gnu.org/software/make/">make</a> to take
advantage of the project <code class="docutils literal"><span class="pre">Makefile</span></code> to compile and run tests.</p>
<p>Once you have your fork and local clone as well as the environment created and
activated, you need to make sure that Python can import the <code class="docutils literal"><span class="pre">fatiando</span></code> code
from your fork. This way, you can make changes and run code to test that your
changes work.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><strong>Don’t</strong> set the <code class="docutils literal"><span class="pre">PYTHONPATH</span></code> environment variable. This can be tricky
under Windows. It’s better to use <code class="docutils literal"><span class="pre">pip</span></code> in editable mode (below).</p>
</div>
<p>First, make sure you have uninstalled Fatiando from your environment (just to
be sure):</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">uninstall</span> <span class="n">fatiando</span>
</pre></div>
</div>
<p>To make it so that Python can find the code in the repository, run <code class="docutils literal"><span class="pre">pip</span>
<span class="pre">install</span></code> in <a class="reference external" href="https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs">editable mode</a>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="o">-</span><span class="n">e</span> <span class="o">.</span>
</pre></div>
</div>
<p>If you’re using the <code class="docutils literal"><span class="pre">Makefile</span></code> you can run <code class="docutils literal"><span class="pre">make</span> <span class="pre">develop</span></code> to do this.</p>
<p>Now, changes to the repository code will be accessible from your installed
Fatiando.</p>
</div>
<div class="section" id="testing">
<span id="develop-test"></span><h2>Testing<a class="headerlink" href="#testing" title="Permalink to this headline">¶</a></h2>
<p>Fatiando uses automated tests to check that the code works and
produces the expected results.
There are two types of tests currently being used:
unit tests and doc tests.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If you are new to automated tests, see the Software Carpentry lessons on
<a class="reference external" href="http://software-carpentry.org/">Testing: Unit Testing</a>.</p>
</div>
<p>Unit tests are implemented in <code class="docutils literal"><span class="pre">tests</span></code> folders inside each subpackage of
<code class="docutils literal"><span class="pre">fatiando</span></code>.
Doctests are part of the docstrings of functions and modules.
You’ll recognize them by the <code class="docutils literal"><span class="pre">>>></span></code> in each line of code.
Both tests are found and run automatically by
<a class="reference external" href="http://pytest.org/">py.test</a>.</p>
<p>There are different ways of running the tests. From the command line using the
<code class="docutils literal"><span class="pre">py.test</span></code> app:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">py</span><span class="o">.</span><span class="n">test</span> <span class="o">--</span><span class="n">doctest</span><span class="o">-</span><span class="n">modules</span> <span class="o">--</span><span class="n">pyargs</span> <span class="n">fatiando</span>
</pre></div>
</div>
<p>Or from Python using the <code class="docutils literal"><span class="pre">fatiando.test</span></code> function:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">fatiando</span>
<span class="n">fatiando</span><span class="o">.</span><span class="n">test</span><span class="p">()</span>
</pre></div>
</div>
<p>Or from the command line using the function:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="o">-</span><span class="n">c</span> <span class="s2">"import fatiando; fatiando.test()"</span>
</pre></div>
</div>
<p>If you use the <code class="docutils literal"><span class="pre">Makefile</span></code>, running <code class="docutils literal"><span class="pre">make</span> <span class="pre">test</span></code> will perform the above in a
temporary folder.</p>
<p>You can also check the test coverage (how much of each module is tested) by:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">py</span><span class="o">.</span><span class="n">test</span> <span class="o">--</span><span class="n">cov</span><span class="o">=</span><span class="n">fatiando</span> <span class="o">--</span><span class="n">doctest</span><span class="o">-</span><span class="n">modules</span> <span class="o">--</span><span class="n">pyargs</span> <span class="n">fatiando</span>
</pre></div>
</div>
<p>or passing <code class="docutils literal"><span class="pre">coverage=True</span></code> to the <code class="docutils literal"><span class="pre">fatiando.test</span></code> function:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="o">-</span><span class="n">c</span> <span class="s2">"import fatiando; fatiando.test(coverage=True)"</span>
</pre></div>
</div>
<div class="admonition important">
<p class="first admonition-title">Important</p>
<p class="last"><strong>All new code contributed must be tested</strong>.
This means that it must have unit
tests and/or doctests that make sure it gives the expected results.
Tests should also make sure that the proper errors happen when the code is
given bad input.
A good balance would be to have both
doctests that run a simple example (they are documentation, after all)
and unit tests that are more elaborate and complete
(using more data, testing corner/special cases, etc).</p>
</div>
<p><strong>Our goal</strong> is to reach at least 90% test coverage
<a class="reference external" href="https://github.com/fatiando/fatiando/issues/102">by version 1.0</a>.</p>
</div>
<div class="section" id="adding-new-code-fixes-docs">
<h2>Adding new code/fixes/docs<a class="headerlink" href="#adding-new-code-fixes-docs" title="Permalink to this headline">¶</a></h2>
<p><strong>All new code</strong> should be committed to a <strong>new branch</strong>.
Fatiando uses the
<a class="reference external" href="http://scottchacon.com/2011/08/31/github-flow.html">“Github Flow”</a>
for managing branches in the repository.
The tutorial <a class="reference external" href="https://guides.github.com/introduction/flow/index.html">“Understanding the Github flow”</a>
offers a quick visual introduction to how that works.
See the <a class="reference internal" href="#develop-pr"><span class="std std-ref">Pull Requests</span></a> section below.</p>
<div class="admonition important">
<p class="first admonition-title">Important</p>
<p class="last">Don’t edit the <em>master</em> branch directly!</p>
</div>
<p>Before working on the code for a new feature/fix/documentation,
you’ll need to create a <em>branch</em> to store your commits.
Make sure you always start your new branch from <em>master</em>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">git</span> <span class="n">checkout</span> <span class="n">master</span>
<span class="n">git</span> <span class="n">checkout</span> <span class="o">-</span><span class="n">b</span> <span class="n">NAME_OF_NEW_BRANCH</span>
</pre></div>
</div>
<p>Replace <code class="docutils literal"><span class="pre">NAME_OF_NEW_BRANCH</span></code> to something relevant to the changes you are
proposing.
For example, <code class="docutils literal"><span class="pre">doc-devel-start-guide</span></code>, <code class="docutils literal"><span class="pre">refactor-gravmag-prism</span></code>,
<code class="docutils literal"><span class="pre">seismic-tomo-module</span></code>, etc.</p>
<div class="admonition important">
<p class="first admonition-title">Important</p>
<p class="last"><strong>Don’t make multiple large changes in a single branch.</strong>
For example,
refactoring a module to make it faster and adding a new function to a
different module.
If you do this, we will only be able to merge your code once <strong>all</strong> new
features are tested, discussed, and documented.
Make separate branches for different things you are working on
(and start all of them from <em>master</em>).
This way we can merge new changes as they are finished instead of having to
wait a long time to merge everything.
It will be even worse if one of the changes is controversial or needs a lot
of discussion and planning.</p>
</div>
<p>Once you have your new branch, you’re all set to start coding/writing.
Remember to run <code class="docutils literal"><span class="pre">make</span> <span class="pre">test</span></code> and check if your changes didn’t break anything.
<strong>Write tests sooner rather than later</strong>.
They will not only help you check if your new code is working properly,
but also provide you with a “deadline” of sorts.
When your code passes your tests, then it is probably “good enough”.</p>
<p>You should consider <a class="reference internal" href="#develop-pr"><span class="std std-ref">openning a Pull Request</span></a>
as soon as have any code that you might want to share.
The sooner you open the PR, the sooner we can start reviewing it and helping
you make your contribution.</p>
</div>
<div class="section" id="code-style">
<h2>Code Style<a class="headerlink" href="#code-style" title="Permalink to this headline">¶</a></h2>
<p>Fatiando follows the <a class="reference external" href="http://legacy.python.org/dev/peps/pep-0008/">PEP8</a>
conventions for code style.</p>
<p>Conformance to PEP8 can be checked automatically using the
<a class="reference external" href="https://pypi.python.org/pypi/pep8">pep8</a> package.
To see which if any code is not following the standard, run:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">pep8</span> <span class="o">--</span><span class="n">show</span><span class="o">-</span><span class="n">source</span> <span class="o">--</span><span class="n">ignore</span><span class="o">=</span><span class="n">W503</span><span class="p">,</span><span class="n">E226</span><span class="p">,</span><span class="n">E241</span> <span class="o">--</span><span class="n">exclude</span><span class="o">=</span><span class="n">_version</span><span class="o">.</span><span class="n">py</span> <span class="n">fatiando</span> <span class="n">cookbook</span> <span class="n">gallery</span>
</pre></div>
</div>
<p>or:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">make</span> <span class="n">pep8</span>
</pre></div>
</div>
<p>This command will tell you exactly which file and line broke PEP8 compliance
and what was wrong with it.</p>
</div>
<div class="section" id="documentation">
<span id="develop-docs"></span><h2>Documentation<a class="headerlink" href="#documentation" title="Permalink to this headline">¶</a></h2>
<p>The documentation for Fatiando is built using
<a class="reference external" href="http://sphinx-doc.org/">sphinx</a>.
The source files for the documentation are in the <code class="docutils literal"><span class="pre">doc</span></code> folder of the
repository.
The most sections of the docs are built from the <code class="docutils literal"><span class="pre">doc/*.rst</span></code> files.
The <a class="reference internal" href="api/fatiando.html#fatiando"><span class="std std-ref">API</span></a> section is automatically built from the
<a class="reference external" href="http://legacy.python.org/dev/peps/pep-0257/">docstrings</a> of
packages, modules, functions, and classes.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Source files and docstrings are written in reStructuredText (rst)
and converted by sphinx to HTML.
This <a class="reference external" href="http://sphinx-doc.org/rest.html">quick guide to rst</a>
is a good reference to get started with rst.</p>
</div>
<p><strong>Docstrings</strong> are formatted in a style particular to Fatiando.
<a class="reference external" href="http://legacy.python.org/dev/peps/pep-0257/">PEP257</a>
has some good general guidelines.
Have a look at the other docstrings in Fatiando and format your own to follow
that style.</p>
<p>Some brief guidelines:</p>
<ul>
<li><p class="first">Module docstrings should include a list of module classes and functions
followed by brief descriptions of each.</p>
</li>
<li><p class="first">Function docstrings:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="o">=</span><span class="mi">4</span><span class="p">):</span>
<span class="sd">r"""</span>
<span class="sd"> Brief description, like 'calculates so and so using bla bla bla'</span>
<span class="sd"> A more detailed description follows after a blank line. Can have</span>
<span class="sd"> multiple paragraphs, citations (Bla et al., 2014), and equations.</span>
<span class="sd"> .. math::</span>
<span class="sd"> g(y) = \int_V y x dx</span>
<span class="sd"> After this, give a full description of ALL parameters the</span>
<span class="sd"> function takes.</span>
<span class="sd"> Parameters:</span>
<span class="sd"> * x : float or numpy array</span>
<span class="sd"> The variable that goes on the horizontal axis. In Meh units.</span>
<span class="sd"> * y : float or numpy array</span>
<span class="sd"> The variable that goes on the vertical axis. In Meh units.</span>
<span class="sd"> Default: 4.</span>
<span class="sd"> Returns:</span>
<span class="sd"> * g : float or numpy array</span>
<span class="sd"> The value of g(y) as calculated by the equation above.</span>
<span class="sd"> Examples:</span>
<span class="sd"> You can include examples as doctests. These are automatically found</span>
<span class="sd"> by the test suite and executed. Lines starting with >>> are code.</span>
<span class="sd"> Lines below them that don't have >>> are the result of that code.</span>
<span class="sd"> The tests compare the given result with what you put as the</span>
<span class="sd"> expected result.</span>
<span class="sd"> >>> foo(3)</span>
<span class="sd"> 25</span>
<span class="sd"> >>> import numpy as np</span>
<span class="sd"> >>> foo(np.array([1, 2])</span>
<span class="sd"> array([ 45. 34. ])</span>
<span class="sd"> References:</span>
<span class="sd"> Include a list of references cited.</span>
<span class="sd"> Bla B., and Meh M. (2014). Some relevant article describing the</span>
<span class="sd"> methods. Journal. doi:82e1hd1puhd7</span>
<span class="sd"> """</span>
</pre></div>
</div>
</li>
<li><p class="first">Class docstrings will contain a description of the class and the parameters
that <cite>__init__</cite> takes. It should also include examples (as doctests when
possible) and references. Pretty much like function docstrings.</p>
</li>
</ul>
<p>You’ll need to install the <a class="reference external" href="https://github.com/ryan-roemer/sphinx-bootstrap-theme">Sphinx bootstrap theme</a> to build the docs.
Run this in your terminal/cmd.exe:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">pip</span> <span class="n">install</span> <span class="n">sphinx_bootstrap_theme</span>
</pre></div>
</div>
<p>To compile the documentation, run:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">cd</span> <span class="n">doc</span>
<span class="n">make</span> <span class="nb">all</span>
</pre></div>
</div>
<p>To view the compiled HTML files, run this inside the <code class="docutils literal"><span class="pre">doc</span></code> folder:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">make</span> <span class="n">serve</span>
</pre></div>
</div>
<p>This will start a server in the <code class="docutils literal"><span class="pre">doc/_build/html</span></code> folder.
Point your browser to <a class="reference external" href="http://127.0.0.1:8008/">http://127.0.0.1:8008</a>
to view the site.
Use <code class="docutils literal"><span class="pre">Ctrl+C</span></code> to stop the server.</p>
</div>
<div class="section" id="pull-requests">
<span id="develop-pr"></span><h2>Pull Requests<a class="headerlink" href="#pull-requests" title="Permalink to this headline">¶</a></h2>
<p>Pull requests (PRs) are how we submit new code and fixes to Fatiando.
The PRs are were your contribution will be revised by other developers.
This works a lot like peer-review does in Science, but we hope you’ll find it a
much nicer experience!</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">To get the general idea of the Pull Request cycle, see
<a class="reference external" href="https://guides.github.com/introduction/flow/index.html">“Understanding the Github flow”</a>.</p>
</div>
<p>After you have your set of changes in a new branch of your <code class="docutils literal"><span class="pre">fatiando</span></code> fork,
make a Pull Request to the <em>master</em> branch of
<a class="reference external" href="https://github.com/fatiando/fatiando">fatiando/fatiando</a>.
Use the main text of the PR to describe in detail what you have done and why.
Explain the purpose of the PR.
What changes are you proposing and why they are
good/awesome/necessary/desirable?
See <a class="reference external" href="https://github.com/fatiando/fatiando/pull/137">PR 137</a> for an example.</p>
<p>PRs serve as a platform for reviewing the code.
Ideally, someone else will go through your code to make sure there aren’t any
obvious mistakes.
The reviewer can also suggest improvements, help with unfixed problems, etc.
This is the same as the peer-review processes in scientific publication
(or at least what it should be).
See the
<a class="reference external" href="https://github.com/fatiando/fatiando/pulls?q=is%3Apr+is%3Amerged">list of completed pull requests</a>
for examples of how the process works.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">Reviewers should <strong>always be polite</strong> in their <strong>constructive</strong> criticism.
Rudeness and prejudice will not be tolerated.
<strong>Beware of wit, humor, and sarcasm</strong>.
It might not always be understood in writting
and not always translates accross native languages.</p>
</div>
<p>PRs will only be merged if they meet certain criteria:</p>
<ul class="simple">
<li>New code must be have <a class="reference internal" href="#develop-test"><span class="std std-ref">automated tests</span></a></li>
<li>All tests must pass (this will be evaluated automatically by
<a class="reference external" href="https://travis-ci.org/fatiando/fatiando/">TravisCI</a>)</li>
<li>All code must follow the
<a class="reference external" href="http://legacy.python.org/dev/peps/pep-0008/">PEP8</a> style conventions.
This will also be check automatically by the tests and TravisCI</li>
<li>All new code and changes must be documented with
<a class="reference internal" href="#develop-docs"><span class="std std-ref">docstrings</span></a></li>
<li>New code must not cause merge conflicts (someone will help you resolve this
in case it happens and you don’t know what to do)</li>
</ul>
<p>Even if all of these requirements are met,
features that fall outside of the scope of the project might not be
accepted (but we will discuss the possibility).
So <strong>before you start coding</strong>
open <a class="reference external" href="https://github.com/fatiando/fatiando/issues">an issue</a> explaining what
you mean to do first so that we can discuss it.
Check if there isn’t an issue open for this already.
This way we can keep track of who is working on what and avoid duplicated work.</p>
<p>To help keep track of what you need to do,
a checklist will be automatically inserted into the pull request description
(adapted from the
<a class="reference external" href="http://khmer.readthedocs.io/en/v1.1/development.html#checklist">khmer docs</a>):</p>
<div class="highlight-default"><div class="highlight"><pre><span></span>## Checklist:
- [ ] Make tests for new code
- [ ] Create/update docstrings
- [ ] Include relevant equations and citations in docstrings
- [ ] Code follows PEP8 style conventions
- [ ] Code and docs have been spellchecked
- [ ] Include new dependencies in docs, README, and .travis.yml
- [ ] Documentation builds properly
- [ ] All tests pass
- [ ] Can be merged
- [ ] Changelog entry (leave for last)
- [ ] Firt-time contributor? Add yourself to `doc/contributors.rst` (leave for last)
</pre></div>
</div>
<p>This will create check boxes that you can mark as you complete each of the
requirements.
If you don’t know how to do some of them, contact a developer
by writing a comment on the PR @-mentioning their user name
(e.g., <a class="reference external" href="https://github.com/leouieda/">@leouieda</a>
or <a class="reference external" href="https://github.com/birocoles/">@birocoles</a>).</p>
</div>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<p class="pull-right">
<a href="#">Back to top</a>
<br/>
<div id="sourcelink">
<a href="_sources/develop.txt"
rel="nofollow">Source</a>
</div>
</p>
<p class="text-center">
© Copyright 2010-2016, Leonardo Uieda.
Created using <a
href="http://sphinx-doc.org/">Sphinx</a> 1.4.8.
</p>
</div>
</footer>
<!-- Load script for fixing the deprecation warning at the top when scrolling -->
<script type="text/javascript" src="_static/fixed_banner.js"></script>
</body>
</html>