Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-17831

Convert sconsUtils to sphinx documentation

    XMLWordPrintable

    Details

    • Story Points:
      2
    • Sprint:
      Arch 2019-02-11
    • Team:
      Architecture

      Description

      Currently sconsUtils requires that doxygen strings be used to create the documentation. This is done because sconsUtils requires that SCons be imported and that is only possible if SCons is importing sconsUtils. Since pydoc and sphinx import python code to extract documentation this makes it hard to use numpydoc.

      For example:

      $ pydoc lsst.sconsUtils
      problem in lsst.sconsUtils - ImportError: lsst.sconsUtils cannot be imported outside an scons script.
      

      It seems though that this is easy to work around. The following patch allows pydoc to work and opens the possibility of migrating sconsUtils away from doxygen.

      diff --git a/python/lsst/sconsUtils/__init__.py b/python/lsst/sconsUtils/__init__.py
      index ee9f02a..6e3c456 100644
      --- a/python/lsst/sconsUtils/__init__.py
      +++ b/python/lsst/sconsUtils/__init__.py
      @@ -1,4 +1,13 @@
       # Explain what happens when you try to import outside scons
      +# When building documentation you want to force a SCons import
      +import os
      +import sys
      +
      +if ("pydoc" in sys.modules or "sphinx" in sys.modules) and "SCONS_DIR" in os.environ:
      +    scons_path = os.path.join(os.environ["SCONS_DIR"], "lib", "scons")
      +    if scons_path not in sys.path:
      +        sys.path.append(scons_path)
      +
       try:
           import SCons.Script
       except ImportError:
      

        Attachments

          Activity

          Hide
          swinbank John Swinbank added a comment -

          Tim Jenness — can you clarify the scope of this ticket, please? Is it supposed to mean “somebody should apply the provided patch”, or “after this patch has been applied (on another ticket?) somebody should edit some docstrings”?

          Show
          swinbank John Swinbank added a comment - Tim Jenness — can you clarify the scope of this ticket, please? Is it supposed to mean “somebody should apply the provided patch”, or “after this patch has been applied (on another ticket?) somebody should edit some docstrings”?
          Hide
          tjenness Tim Jenness added a comment -

          The scope was meant to be to update the sconsUtils docstrings and integrate into Sphinx (which I've done because I was clearly bored over the weekend).

          Show
          tjenness Tim Jenness added a comment - The scope was meant to be to update the sconsUtils docstrings and integrate into Sphinx (which I've done because I was clearly bored over the weekend).
          Hide
          tjenness Tim Jenness added a comment -

          My proposed patch does allow Sphinx to build the documentation. I have ported all the doxygen to numpydoc (some of it was already numpydoc) and added a sphinx build. There is one remaining problem in that all the methods that are inserted into SConsEnvironment at import time are not picked up by Sphinx and it complains that they are not part of the toctree. Maybe it would work to create a dummy class that inherits from SConsEnvironment.

          Show
          tjenness Tim Jenness added a comment - My proposed patch does allow Sphinx to build the documentation. I have ported all the doxygen to numpydoc (some of it was already numpydoc) and added a sphinx build. There is one remaining problem in that all the methods that are inserted into SConsEnvironment at import time are not picked up by Sphinx and it complains that they are not part of the toctree. Maybe it would work to create a dummy class that inherits from SConsEnvironment.
          Hide
          jsick Jonathan Sick added a comment -

          Brilliant! I like it. Shall we add this to the pipelines_lsst_io table file?

          Show
          jsick Jonathan Sick added a comment - Brilliant! I like it. Shall we add this to the pipelines_lsst_io  table file?
          Hide
          ktl Kian-Tat Lim added a comment -

          Looked through most of it, but with a pretty coarse comb that might have missed some stuff.  It looks like a definite improvement.

          Show
          ktl Kian-Tat Lim added a comment - Looked through most of it, but with a pretty coarse comb that might have missed some stuff.  It looks like a definite improvement.
          Hide
          tjenness Tim Jenness added a comment -

          Thanks for the reviews. Merged. Jonathan Sick feel free to add to pipelines.lsst.io.

          Show
          tjenness Tim Jenness added a comment - Thanks for the reviews. Merged. Jonathan Sick feel free to add to pipelines.lsst.io.

            People

            Assignee:
            tjenness Tim Jenness
            Reporter:
            tjenness Tim Jenness
            Reviewers:
            Kian-Tat Lim
            Watchers:
            Jim Bosch, John Swinbank, Jonathan Sick, Kian-Tat Lim, Tim Jenness
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Jenkins

                No builds found.