Closed sobester closed 4 years ago
Can you attach the HTML output file? I'll wager it's the highlighting engine auto-detecting the wrong language.
here is the link to the html: https://www.dropbox.com/s/p1qoke0ko0xcy1l/constraintanalysis.html?dl=0
The issue appears to be that Highlight.js for some reason recognizes your code snippet as Makefile code. You can force the code language using fenced-code blocks with language specification instead of indented blocks, i.e.:
EXAMPLE
-------
```python
import constraintanalysis as ca
import atmospheres as at
import unitconversions as co
...
```
Other than that, this looks like an upstream issue. Filed as https://github.com/highlightjs/highlight.js/issues/1976.
The fence code blocks method seems to do the trick! Many thanks.
I have a similar issue, that maybe goes under what am I doing wrong/is this right?
I see the above example @kernc uses markdown back ticks (``) in his docstring. Is this how you get the highlighting I see in this example, pymap3d?
I ask because I see that pdoc states that it has supported docstring formats (numpy, google), but I do not see any examples of what I should expect if I use these formats.
I have a project that uses numpy style docstrings and it just comes out looking like text. I also cloned the above pymap3d and ran pdoc and got the same result, which is unformatted text docstrings.
<section class="desc"><p>converts target azimuth, elevation, range from observer at lat0,lon0,alt0 to ECEF coordinates.</p>
<h2 id="parameters">Parameters</h2>
<dl>
<dt><strong><code>az</code></strong> : <code>float</code> or <code>numpy.ndarray</code> of <code>float</code></dt>
<dd>azimuth to target</dd>
<dt><strong><code>el</code></strong> : <code>float</code> or <code>numpy.ndarray</code> of <code>float</code></dt>
<dd>elevation to target</dd>
<dt><strong><code>srange</code></strong> : <code>float</code> or <code>numpy.ndarray</code> of <code>float</code></dt>
<dd>slant range [meters]</dd>
<dt><strong><code>lat0</code></strong> : <code>float</code></dt>
<dd>Observer geodetic latitude</dd>
<dt><strong><code>lon0</code></strong> : <code>float</code></dt>
<dd>Observer geodetic longitude</dd>
<dt><strong><code>h0</code></strong> : <code>float</code></dt>
<dd>observer altitude above geodetic ellipsoid (meters)</dd>
<dt><strong><code>ell</code></strong> : <code>Ellipsoid</code>, optional</dt>
<dd>reference ellipsoid</dd>
<dt><strong><code>deg</code></strong> : <code>bool</code>, optional</dt>
<dd>degrees input/output
(False: radians in/out)</dd>
</dl>
<h2 id="returns">Returns</h2>
<p>ECEF (Earth centered, Earth fixed)
x,y,z</p>
<dl>
<dt><strong><code>x</code></strong> : <code>float</code> or <code>numpy.ndarray</code> of <code>float</code></dt>
<dd>ECEF x coordinate (meters)</dd>
<dt><strong><code>y</code></strong> : <code>float</code> or <code>numpy.ndarray</code> of <code>float</code></dt>
<dd>ECEF y coordinate (meters)</dd>
<dt><strong><code>z</code></strong> : <code>float</code> or <code>numpy.ndarray</code> of <code>float</code></dt>
<dd>ECEF z coordinate (meters)</dd>
</dl>
<h2 id="notes">Notes</h2>
<p>if srange==NaN, z=NaN</p></section>
<div class="desc"><p>converts target azimuth, elevation, range from observer at lat0,lon0,alt0 to ECEF coordinates.</p>
<h2>Parameters</h2>
<p>az : float or numpy.ndarray of float
azimuth to target
el : float or numpy.ndarray of float
elevation to target
srange : float or numpy.ndarray of float
slant range [meters]
lat0 : float
Observer geodetic latitude
lon0 : float
Observer geodetic longitude
h0 : float
observer altitude above geodetic ellipsoid (meters)
ell : Ellipsoid, optional
reference ellipsoid
deg : bool, optional
degrees input/output (False: radians in/out)</p>
<h2>Returns</h2>
<p>ECEF (Earth centered, Earth fixed) x,y,z</p>
<p>x : float or numpy.ndarray of float
ECEF x coordinate (meters)
y : float or numpy.ndarray of float
ECEF y coordinate (meters)
z : float or numpy.ndarray of float
ECEF z coordinate (meters)</p>
<h2>Notes</h2>
<p>if srange==NaN, z=NaN</p></div>
I just am not sure if I need to add markdown formatting manually or if I am not doing something correctly.
@jetilton Please open a new issue for this. The output should be as you expect it.
Upstream fixed https://github.com/highlightjs/highlight.js/issues/1976. Workaround (using fenced-code blocks) exists.
Expected Behavior
Syntax highlighting in code snipets in docstring
Actual Behavior
Syntax highlighted beautifully in some cases, partially in others (only some keywords, etc.), not at all in yet others.
Steps to Reproduce
Here is an example function where the resulting HTML has the code all in grey:
Other, seemingly very similar docstrings in the same .py file are highlighted very nicely, for example:
I cannot figure what I'm doing right in one but not in the other...
Many thanks for the great tool.
Additional info