alex-rudakov / sphinx-argparse

Sphinx extension that automatically document argparse commands and options
MIT License
49 stars 40 forks source link

0.2.5: setuptools build_sphinx target is failing #138

Open kloczek opened 3 years ago

kloczek commented 3 years ago
+ /usr/bin/python3 setup.py build_sphinx -b man
running build_sphinx
Running Sphinx v4.0.2

Configuration error:
There is a programmable error in your configuration file:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/sphinx/config.py", line 323, in eval_config_file
    exec(code, namespace)
  File "/home/tkloczko/rpmbuild/BUILD/sphinx-argparse-0.2.5/docs/conf.py", line 64, in <module>
    version = pkg_resources.require("version")
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 901, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 787, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'version' distribution was not found and is required by the application
kloczek commented 3 years ago

BTW I was forced to use souece tree from git repo because i sdist tar ball there is no docs/ direcrory with documentation.

kloczek commented 3 years ago

Here is the patch which fixes building documentation:

--- a/docs/sample.rst~  2018-11-14 14:03:22.000000000 +0000
+++ b/docs/sample.rst   2021-08-05 11:17:05.688468094 +0100
@@ -72,7 +72,7 @@
 Source::

     .. argparse::
-       :filename: ../test/sample.py
+       :filename: test/sample.py
        :func: parser
        :prog: sample

@@ -80,7 +80,7 @@
 ~~~~~~

 .. argparse::
-    :filename: ../test/sample.py
+    :filename: test/sample.py
     :func: parser
     :prog: sample

@@ -94,7 +94,7 @@
 Source::

     .. argparse::
-       :filename../test/sample.py
+       :filenametest/sample.py
        :func: parser
        :prog: sample
        :path: game
@@ -103,7 +103,7 @@
 ~~~~~~

 .. argparse::
-   :filename: ../test/sample.py
+   :filename: test/sample.py
    :func: parser
    :prog: sample
    :path: game
--- a/docs/markdown.rst~        2018-11-14 14:03:22.000000000 +0000
+++ b/docs/markdown.rst 2021-08-05 11:16:42.878418623 +0100
@@ -4,7 +4,7 @@
 As of version 0.2.0, markdown (rather than only reStructuredText) can be included inside directives as nested content. While markdown is much easier to write, please note that it is also less powerful. An example is below::

    .. argparse::
-       :filename: ../test/sample.py
+       :filename: test/sample.py
        :func: parser
        :prog: sample
        :markdown:
@@ -28,7 +28,7 @@
 The above example renders as follows:

 .. argparse::
-    :filename: ../test/sample.py
+    :filename: test/sample.py
     :func: parser
     :prog: sample
     :markdown:
@@ -89,7 +89,7 @@
 To render this as MarkDown rather than reStructuredText, use the `markdownhelp` option::

     .. argparse::
-        :filename: ../test/sample2.py
+        :filename: test/sample2.py
         :func: blah
         :prog: sample
         :markdownhelp:
@@ -97,7 +97,7 @@
 This will then be rendered as:

 .. argparse::
-    :filename: ../test/sample2.py
+    :filename: test/sample2.py
     :func: blah
     :prog: sample
     :markdownhelp:

Result with that patch:

[tkloczko@barrel sphinx-argparse-0.2.5]$ /usr/bin/python3 setup.py build_sphinx -b man --build-dir build/sphinx
running build_sphinx
Running Sphinx v4.1.2
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [man]: all manpages
updating environment: 0 added, 1 changed, 0 removed
reading sources... [100%] sample
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
writing... python-sphinx-argparse.3 { install usage extend sample misc markdown changelog contrib } done
build succeeded.

Do you want me to open PR?

kloczek commented 3 years ago

And yoe t another detail. You are using pkg_resources.require("version") in copy.py which is causing that it needs venv to build documentation or module needs to be first installed. Below patch allows build documentation without those steps.

--- a/docs/conf.py~     2021-08-05 10:58:15.000000000 +0100
+++ b/docs/conf.py      2021-08-05 11:01:26.113250065 +0100
@@ -61,7 +61,7 @@
 # The short X.Y version.

 import pkg_resources  # part of setuptools
-version = pkg_resources.require("version")
+version = '0.2.5'

 # The full version, including alpha/beta/rc tags.
 release = version
kloczek commented 2 years ago

ping ..?

JOJ0 commented 2 years ago

@kloczek this repo is abandoned. use https://github.com/ashb/sphinx-argparse

I am sure your PR will be welcome there :-)

kloczek commented 2 years ago

Just tested that forrk and all builds cleanly. Only missig bit is missing residual setup.py to be able use setuptools<>sphinx integration. Hopefully my workaround in such situations wit echo 'from setuptools import setup; setup()' > setup.py will be possible replace by some generic build module integration with sphinx.