summaryrefslogtreecommitdiff
path: root/developer/contribute.html
diff options
context:
space:
mode:
Diffstat (limited to 'developer/contribute.html')
-rw-r--r--developer/contribute.html131
1 files changed, 81 insertions, 50 deletions
diff --git a/developer/contribute.html b/developer/contribute.html
index abf9e6ac..a55159d6 100644
--- a/developer/contribute.html
+++ b/developer/contribute.html
@@ -852,22 +852,73 @@ detailing the test coverage:</p>
<span class="o">...</span>
</pre></div>
</div>
-</section>
<section id="adding-tests">
-<h2>Adding tests<a class="headerlink" href="#adding-tests" title="Permalink to this heading">#</a></h2>
+<h3>Adding tests<a class="headerlink" href="#adding-tests" title="Permalink to this heading">#</a></h3>
<p>If you’re <strong>new to testing</strong>, see existing test files for examples of things to do.
<strong>Don’t let the tests keep you from submitting your contribution!</strong>
If you’re not sure how to do this or are having trouble, submit your pull request
anyway.
We will help you create the tests and sort out any kind of problem during code review.</p>
</section>
+<section id="image-comparison">
+<h3>Image comparison<a class="headerlink" href="#image-comparison" title="Permalink to this heading">#</a></h3>
+<p>To run image comparisons:</p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ PYTHONPATH=. pytest --mpl --pyargs networkx.drawing
+</pre></div>
+</div>
+<p>The <code class="docutils literal notranslate"><span class="pre">--mpl</span></code> tells <code class="docutils literal notranslate"><span class="pre">pytest</span></code> to use <code class="docutils literal notranslate"><span class="pre">pytest-mpl</span></code> to compare the generated plots
+with baseline ones stored in <code class="docutils literal notranslate"><span class="pre">networkx/drawing/tests/baseline</span></code>.</p>
+<p>To add a new test, add a test function to <code class="docutils literal notranslate"><span class="pre">networkx/drawing/tests</span></code> that
+returns a Matplotlib figure (or any figure object that has a savefig method)
+and decorate it as follows:</p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@pytest</span><span class="o">.</span><span class="n">mark</span><span class="o">.</span><span class="n">mpl_image_compare</span>
+<span class="k">def</span> <span class="nf">test_barbell</span><span class="p">():</span>
+ <span class="n">fig</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">()</span>
+ <span class="n">barbell</span> <span class="o">=</span> <span class="n">nx</span><span class="o">.</span><span class="n">barbell_graph</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">)</span>
+ <span class="c1"># make sure to fix any randomness</span>
+ <span class="n">pos</span> <span class="o">=</span> <span class="n">nx</span><span class="o">.</span><span class="n">spring_layout</span><span class="p">(</span><span class="n">barbell</span><span class="p">,</span> <span class="n">seed</span><span class="o">=</span><span class="mi">42</span><span class="p">)</span>
+ <span class="n">nx</span><span class="o">.</span><span class="n">draw</span><span class="p">(</span><span class="n">barbell</span><span class="p">,</span> <span class="n">pos</span><span class="o">=</span><span class="n">pos</span><span class="p">)</span>
+ <span class="k">return</span> <span class="n">fig</span>
+</pre></div>
+</div>
+<p>Then create a baseline image to compare against later:</p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ pytest -k test_barbell --mpl-generate-path=networkx/drawing/tests/baseline
+</pre></div>
+</div>
+<p>And test:</p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ pytest -k test_barbell --mpl
+</pre></div>
+</div>
+</section>
+</section>
+<section id="documentation">
+<h2>Documentation<a class="headerlink" href="#documentation" title="Permalink to this heading">#</a></h2>
+<p>Building the documentation locally requires that the additional dependencies
+specified in <code class="docutils literal notranslate"><span class="pre">requirements/doc.txt</span></code> be installed in your development
+environment.</p>
+<p>The documentation is built with <code class="docutils literal notranslate"><span class="pre">sphinx</span></code>. To build the documentation locally,
+navigate to the <code class="docutils literal notranslate"><span class="pre">doc/</span></code> directory and:</p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">make</span> <span class="n">html</span>
+</pre></div>
+</div>
+<p>This will generate both the reference documentation as well as the example
+gallery. If you want to build the documentation <em>without</em> building the
+gallery examples use:</p>
+<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">make</span> <span class="n">html</span><span class="o">-</span><span class="n">noplot</span>
+</pre></div>
+</div>
+<p>The build products are stored in <code class="docutils literal notranslate"><span class="pre">doc/build/</span></code> and can be viewed directly.
+For example, to view the built html, open <code class="docutils literal notranslate"><span class="pre">build/html/index.html</span></code>
+in your preferred web browser.</p>
<section id="adding-examples">
-<h2>Adding examples<a class="headerlink" href="#adding-examples" title="Permalink to this heading">#</a></h2>
+<h3>Adding examples<a class="headerlink" href="#adding-examples" title="Permalink to this heading">#</a></h3>
<p>The gallery examples are managed by
<a class="reference external" href="https://sphinx-gallery.readthedocs.io/">sphinx-gallery</a>.
The source files for the example gallery are <code class="docutils literal notranslate"><span class="pre">.py</span></code> scripts in <code class="docutils literal notranslate"><span class="pre">examples/</span></code> that
generate one or more figures. They are executed automatically by sphinx-gallery when the
documentation is built. The output is gathered and assembled into the gallery.</p>
+<p>Building the example gallery locally requires that the additional dependencies
+in <code class="docutils literal notranslate"><span class="pre">requirements/example.txt</span></code> be installed in your development environment.</p>
<p>You can <strong>add a new</strong> plot by placing a new <code class="docutils literal notranslate"><span class="pre">.py</span></code> file in one of the directories inside the
<code class="docutils literal notranslate"><span class="pre">examples</span></code> directory of the repository. See the other examples to get an idea for the
format.</p>
@@ -886,7 +937,7 @@ documentation.</p></li>
</ul>
</section>
<section id="adding-references">
-<h2>Adding References<a class="headerlink" href="#adding-references" title="Permalink to this heading">#</a></h2>
+<h3>Adding References<a class="headerlink" href="#adding-references" title="Permalink to this heading">#</a></h3>
<p>If you are contributing a new algorithm (or an improvement to a current algorithm),
a reference paper or resource should also be provided in the function docstring.
For references to published papers, we try to follow the
@@ -909,35 +960,6 @@ to use the <a class="reference external" href="https://web.archive.org/">wayback
and link the internet archive link. The URL of the resource can change, and it creates unreachable
links from the documentation.</p>
</section>
-<section id="image-comparison">
-<h2>Image comparison<a class="headerlink" href="#image-comparison" title="Permalink to this heading">#</a></h2>
-<p>To run image comparisons:</p>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ PYTHONPATH=. pytest --mpl --pyargs networkx.drawing
-</pre></div>
-</div>
-<p>The <code class="docutils literal notranslate"><span class="pre">--mpl</span></code> tells <code class="docutils literal notranslate"><span class="pre">pytest</span></code> to use <code class="docutils literal notranslate"><span class="pre">pytest-mpl</span></code> to compare the generated plots
-with baseline ones stored in <code class="docutils literal notranslate"><span class="pre">networkx/drawing/tests/baseline</span></code>.</p>
-<p>To add a new test, add a test function to <code class="docutils literal notranslate"><span class="pre">networkx/drawing/tests</span></code> that
-returns a Matplotlib figure (or any figure object that has a savefig method)
-and decorate it as follows:</p>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@pytest</span><span class="o">.</span><span class="n">mark</span><span class="o">.</span><span class="n">mpl_image_compare</span>
-<span class="k">def</span> <span class="nf">test_barbell</span><span class="p">():</span>
- <span class="n">fig</span> <span class="o">=</span> <span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">()</span>
- <span class="n">barbell</span> <span class="o">=</span> <span class="n">nx</span><span class="o">.</span><span class="n">barbell_graph</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">6</span><span class="p">)</span>
- <span class="c1"># make sure to fix any randomness</span>
- <span class="n">pos</span> <span class="o">=</span> <span class="n">nx</span><span class="o">.</span><span class="n">spring_layout</span><span class="p">(</span><span class="n">barbell</span><span class="p">,</span> <span class="n">seed</span><span class="o">=</span><span class="mi">42</span><span class="p">)</span>
- <span class="n">nx</span><span class="o">.</span><span class="n">draw</span><span class="p">(</span><span class="n">barbell</span><span class="p">,</span> <span class="n">pos</span><span class="o">=</span><span class="n">pos</span><span class="p">)</span>
- <span class="k">return</span> <span class="n">fig</span>
-</pre></div>
-</div>
-<p>Then create a baseline image to compare against later:</p>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ pytest -k test_barbell --mpl-generate-path=networkx/drawing/tests/baseline
-</pre></div>
-</div>
-<p>And test:</p>
-<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ pytest -k test_barbell --mpl
-</pre></div>
-</div>
</section>
<section id="bugs">
<h2>Bugs<a class="headerlink" href="#bugs" title="Permalink to this heading">#</a></h2>
@@ -1009,26 +1031,35 @@ and decorate it as follows:</p>
<a class="reference internal nav-link" href="#testing">
Testing
</a>
+ <ul class="nav section-nav flex-column">
+ <li class="toc-h3 nav-item toc-entry">
+ <a class="reference internal nav-link" href="#adding-tests">
+ Adding tests
+ </a>
+ </li>
+ <li class="toc-h3 nav-item toc-entry">
+ <a class="reference internal nav-link" href="#image-comparison">
+ Image comparison
+ </a>
+ </li>
+ </ul>
</li>
<li class="toc-h2 nav-item toc-entry">
- <a class="reference internal nav-link" href="#adding-tests">
- Adding tests
- </a>
- </li>
- <li class="toc-h2 nav-item toc-entry">
- <a class="reference internal nav-link" href="#adding-examples">
- Adding examples
- </a>
- </li>
- <li class="toc-h2 nav-item toc-entry">
- <a class="reference internal nav-link" href="#adding-references">
- Adding References
- </a>
- </li>
- <li class="toc-h2 nav-item toc-entry">
- <a class="reference internal nav-link" href="#image-comparison">
- Image comparison
+ <a class="reference internal nav-link" href="#documentation">
+ Documentation
</a>
+ <ul class="nav section-nav flex-column">
+ <li class="toc-h3 nav-item toc-entry">
+ <a class="reference internal nav-link" href="#adding-examples">
+ Adding examples
+ </a>
+ </li>
+ <li class="toc-h3 nav-item toc-entry">
+ <a class="reference internal nav-link" href="#adding-references">
+ Adding References
+ </a>
+ </li>
+ </ul>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#bugs">