alendit / sphinx-pyreverse

Simple sphinx wrapper around pyreverse (from pylint suit) to generate UML diagramms from modules.
GNU General Public License v3.0
48 stars 20 forks source link

Extra ".." in image path if the uml directive is used in submodule #26

Closed Nic30 closed 3 years ago

Nic30 commented 3 years ago

I am using:

astroid==2.4.2
pylint==2.6.0
sphinx-pyreverse

https://github.com/Nic30/hdlConvertorAst/blob/master/hdlConvertorAst/hdlAst/__init__.py#L17 https://hdlconvertorast.readthedocs.io/en/latest/hdlConvertorAst.hdlAst.html

reading sources... [ 14%] hdlConvertorAst.hdlAst
sphinx-pyreverse: Running: pyreverse --output png --project hdlConvertorAst.hdlAst hdlConvertorAst.hdlAst
...
.../hdlConvertorAst/hdlAst/__init__.py:docstring of hdlConvertorAst.hdlAst:: WARNING: image file not readable: ../../doc/uml_images/classes_hdlConvertorAst.hdlAst.png
...
.../hdlConvertorAst/hdlAst/__init__.py:docstring of hdlConvertorAst.hdlAst:: WARNING: Could not obtain image size. :scale: option is ignored.
....

build succeeded, 12 warnings.

The file is really there just the path is wrong. Should I use a different combination of packages or there is a bug?

Nic30 commented 3 years ago

Also I do have some "sphinx extension test runner" which may be helpful https://github.com/Nic30/sphinx-hwt/tree/master/tests It is not much but it works.

doublethefish commented 3 years ago

Apologies, this fell off our radar.

I personally don't have time to look at this, but please feel free to either add a test demonstrating the issue.

We've just moved the tests to pytest making each test more sandboxed along the way, so it should be a tad easier to add new tests.

Also, feel free to raise a separate PR for integrating the sphinx extension test runner.

I suspect the problem is in the folowing code in generate_img:

        path_from_base = os.path.join(self.DIR_NAME, "{1}_{0}.{2}").format(
            module_name, img_name, config.sphinx_pyreverse_output
        )
        # use relpath to get sub-directory of the main 'source' location
        src_base = os.path.relpath(base_dir, start=src_dir)
        uri = directives.uri(os.path.join(src_base, path_from_base))
Nic30 commented 3 years ago

Hello @doublethefish, the fix would help me a lot. I am having the doc with missing images for more than 0.5y. I am currently in hurry because of some conferences and I am not familiar with you tests, do you think you can fix it?

doublethefish commented 3 years ago

Not now, I'm only a volunteer and I am paying the bills myself ;)

But I have written a quick test that doesn't show your issue but it should if the issue exists. It suggests that perhaps you have something funky in your path or sphinx setup. E.g. try setting PYTHONPATH.

The test (meta) is:

    # for each of the types of submodule below
    ["parent_only", "parent.submodule", "parent.submodule.nestedsubmodule"]
    [..snip..]
    # check that the output is invariant
    assert uri == f"../BASE_DIR/uml_images/IMG_NAME_{module_address}.png"
    assert output_file == f"BASE_DIR/uml_images/IMG_NAME_{module_address}.png"

That should be a good starter for 10 for you :)

doublethefish commented 3 years ago

It suggests that perhaps you have something funky in your path or sphinx setup. E.g. try setting PYTHONPATH.

In fact, I am so confident in this, based on that test, I will close this for now.

If I am wrong and you can provide either a minimal repro case or a test that shows it please reopen, I'll be more than happy to look at it when I get a bit of time :)