xarray icon indicating copy to clipboard operation
xarray copied to clipboard

Add sphinx-codeautolink extension to docs build

Open TomNicholas opened this issue 1 year ago • 2 comments

I think that sphinx-codeautolink is different from sphinx.ext.linkcode...

  • [x] Closes #7010
  • [ ] Tests added
  • [ ] User visible changes (including notable bug fixes) are documented in whats-new.rst
  • [ ] New functions/methods are listed in api.rst

TomNicholas avatar Sep 08 '22 17:09 TomNicholas

I don't understand why this failed - it works when I build the docs locally, but the RTD build doesn't give me a useful error message...

TomNicholas avatar Sep 08 '22 19:09 TomNicholas

did you compare the versions? If it works locally, maybe you have a different version of sphinx or sphinx-codeautolink (or any other dependency?)

keewis avatar Sep 08 '22 22:09 keewis

There are a lot of these warnings:

/home/docs/checkouts/readthedocs.org/user_builds/xray/checkouts/7011/doc/whats-new.rst:1: WARNING: invalid syntax (<unknown>, line 6) in document "whats-new"
Parsed source in `ipython` block:
block source: In [66]: ds = xray.Dataset({"x": np.arange(1000)})
              
              In [67]: with xray.set_options(display_width=40):
                 ....:     print(ds)
                 ....: 
              <xarray.Dataset>
              Dimensions:  (x: 1000)
              Coordinates:
                * x        (x) int64 0 1 2 ... 998 999
              Data variables:
                  *empty*

dcherian avatar Nov 04 '22 23:11 dcherian

Hi, it looks like the print output is recognised as Python code and parsed. This shouldn't be happening since your what's-new correctly contains the Out [...]: prefixes which we use to ignore lines for parsing (although I couldn't find the specific case you presented). I'll test the multiline outputs and provide an update to you.

felix-hilden avatar Nov 05 '22 11:11 felix-hilden

Yep, a weird interaction between rST processing and the IPython transformer. This class of issues fixed in sphinx-codeautolink==0.12.1!

felix-hilden avatar Nov 05 '22 12:11 felix-hilden