Git Product home page Git Product logo

symbiflow / sphinxcontrib-hdl-diagrams Goto Github PK

View Code? Open in Web Editor NEW
52.0 52.0 17.0 157 KB

Sphinx Extension which generates various types of diagrams from Verilog code.

Home Page: https://sphinxcontrib-hdl-diagrams.rtfd.io

License: Apache License 2.0

Python 84.27% Makefile 9.93% Verilog 5.80%
diagrams documentation documentation-tool fpga hdl rtl sphinx sphinx-extension symbiflow verilog yosys

sphinxcontrib-hdl-diagrams's People

Contributors

daniellimws avatar mglb avatar mithro avatar oharboe avatar rw1nkler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sphinxcontrib-hdl-diagrams's Issues

skywater-pdk documentation generation failing due to "annot import name 'ENOENT' from 'sphinx.util.osutil'" which is somehow related to sphinxcontrib_hdl_diagrams

https://readthedocs.org/projects/skywater-pdk/builds/14408706/

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/site-packages/sphinx/registry.py", line 429, in load_extension
    mod = import_module(extname)
  File "/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/site-packages/sphinxcontrib_hdl_diagrams/__init__.py", line 45, in <module>
    from sphinx.util.osutil import ensuredir, ENOENT, EPIPE, EINVAL
ImportError: cannot import name 'ENOENT' from 'sphinx.util.osutil' (/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/site-packages/sphinx/util/osutil.py)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/site-packages/sphinx/cmd/build.py", line 276, in build_main
    app = Sphinx(args.sourcedir, args.confdir, args.outputdir,
  File "/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/site-packages/sphinx/application.py", line 237, in __init__
    self.setup_extension(extension)
  File "/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/site-packages/sphinx/application.py", line 393, in setup_extension
    self.registry.load_extension(self, extname)
  File "/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/site-packages/sphinx/registry.py", line 432, in load_extension
    raise ExtensionError(__('Could not import extension %s') % extname,
sphinx.errors.ExtensionError: Could not import extension sphinxcontrib_hdl_diagrams (exception: cannot import name 'ENOENT' from 'sphinx.util.osutil' (/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/site-packages/sphinx/util/osutil.py))

Extension error:
Could not import extension sphinxcontrib_hdl_diagrams (exception: cannot import name 'ENOENT' from 'sphinx.util.osutil' (/home/docs/checkouts/readthedocs.org/user_builds/skywater-pdk/conda/333/lib/python3.8/site-packages/sphinx/util/osutil.py))

Readme Rst is broken

https://travis-ci.com/github/SymbiFlow/sphinxcontrib-verilog-diagrams/builds/172946780

Checking dist/sphinxcontrib_verilog_diagrams-0.0.post79-py3-none-any.whl: FAILED
  `long_description` has syntax errors in markup and would not be rendered on PyPI.
    line 81: Warning: Bullet list ends without a blank line; unexpected unindent.
Checking dist/sphinxcontrib-verilog-diagrams-0.0.post79.tar.gz: FAILED
  `long_description` has syntax errors in markup and would not be rendered on PyPI.
    line 81: Warning: Bullet list ends without a blank line; unexpected unindent.

Guess we should figure out how to test for that in a pull request?

Document the no-license-include stuff

In #20 @daniellimws added functionality to skip the license when including a verilog file.

It appears we didn't add documentation at all?

We should put;

  • Explicit examples which show the difference in the readthedocs output.
  • Example in the README.md file.

Build failing on readthedocs

https://readthedocs.org/projects/sphinxcontrib-verilog-diagrams/builds/11085867/

looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] index
ERROR: Command syntax error: Unknown option or option in arguments.
> write_json -compat-int /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/_build/html/_images/index-108-verilog-dff.json
>            ^
Running yosys: yosys -p 'prep -top top ; cd top; show -format svg -prefix /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/_build/html/_images/index-68-verilog-dff' /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/verilog/dff.v
Output file created: /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/_build/html/_images/index-68-verilog-dff.svg
Running yosys: yosys -p 'prep -top top ; cd top; show -format svg -prefix /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/_build/html/_images/index-88-verilog-dff' /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/verilog/dff.v
Output file created: /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/_build/html/_images/index-88-verilog-dff.svg
Running yosys: yosys -p 'prep -top top ; cd top; write_json -compat-int /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/_build/html/_images/index-108-verilog-dff.json' /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/verilog/dff.v
/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/deprecation.py:52: RemovedInSphinx40Warning: sphinx.builders.html.DirectoryHTMLBuilder is deprecated. Check CHANGES for Sphinx API modifications.
  return getattr(self._module, name)
/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/readthedocs_ext/readthedocs.py:14: RemovedInSphinx40Warning: sphinx.builders.html.SingleFileHTMLBuilder is deprecated. Check CHANGES for Sphinx API modifications.
  from sphinx.builders.html import (DirectoryHTMLBuilder, SingleFileHTMLBuilder,

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/cmd/build.py", line 280, in build_main
    app.build(args.force_all, filenames)
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/application.py", line 348, in build
    self.builder.build_update()
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 299, in build_update
    len(to_build))
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 361, in build
    self.write(docnames, list(updated_docnames), method)
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 535, in write
    self._write_serial(sorted(docnames))
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 545, in _write_serial
    self.write_doc(docname, doctree)
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/builders/html/__init__.py", line 597, in write_doc
    self.docwriter.write(doctree, destination)
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/docutils/writers/__init__.py", line 78, in write
    self.translate()
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/writers/html.py", line 71, in translate
    self.document.walkabout(visitor)
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/docutils/nodes.py", line 214, in walkabout
    if child.walkabout(visitor):
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/docutils/nodes.py", line 214, in walkabout
    if child.walkabout(visitor):
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/docutils/nodes.py", line 214, in walkabout
    if child.walkabout(visitor):
  [Previous line repeated 2 more times]
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/docutils/nodes.py", line 206, in walkabout
    visitor.dispatch_visit(self)
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/site-packages/sphinx/util/docutils.py", line 468, in dispatch_visit
    method(node)
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/sphinxcontrib_verilog_diagrams.py", line 338, in html_visit_verilog_diagram
    render_diagram_html(self, node, node['code'], node['options'])
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/sphinxcontrib_verilog_diagrams.py", line 309, in render_diagram_html
    fname, outfn = render_diagram(self, code, options, format)
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/sphinxcontrib_verilog_diagrams.py", line 291, in render_diagram
    verilog_path, outfn, module=options['module'], flatten=options['flatten'])
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/sphinxcontrib_verilog_diagrams.py", line 261, in diagram_netlistsvg
    """.format(top=module, flatten=flatten, ojson=ojson).strip())
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/sphinxcontrib_verilog_diagrams.py", line 202, in run_yosys
    subprocess.check_output(ycmd, shell=True)
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/subprocess.py", line 411, in check_output
    **kwargs).stdout
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/subprocess.py", line 512, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'yosys -p 'prep -top top ; cd top; write_json -compat-int /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/_build/html/_images/index-108-verilog-dff.json' /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/verilog/dff.v' returned non-zero exit status 1.

Exception occurred:
  File "/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/conda/latest/lib/python3.7/subprocess.py", line 512, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'yosys -p 'prep -top top ; cd top; write_json -compat-int /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/_build/html/_images/index-108-verilog-dff.json' /home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-verilog-diagrams/checkouts/latest/docs/verilog/dff.v' returned non-zero exit status 1.
The full traceback has been saved in /tmp/sphinx-err-5duhsu2j.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!

Fix sphinx errors

OS_TYPE=Linux CPU_TYPE=x86_64
'name: sphinxcontrib-verilog-diagrams' 'sphinxcontrib-verilog-diagrams'
source /home/tim/github/SymbiFlow/sphinxcontrib-verilog-diagrams/env/conda/bin/activate sphinxcontrib-verilog-diagrams && cd docs; make html
make[1]: Entering directory '/home/tim/github/SymbiFlow/sphinxcontrib-verilog-diagrams/docs'
Running Sphinx v3.1.1
making output directory... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 1 source files that are out of date
updating environment: [new config] 1 added, 0 changed, 0 removed
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853d4b290>                                                                      
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853dbe5d0>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853d619d0>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853d059d0>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853d1d850>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853d05490>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853d05410>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853da37d0>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853d3bed0>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853ccf2d0>
verilog-diagram <sphinxcontrib_verilog_diagrams.VerilogDiagram object at 0x7f6853ccf390>

/home/tim/github/SymbiFlow/sphinxcontrib-verilog-diagrams/docs/index.rst:38: WARNING: Error in "code-block" directive:
maximum 1 argument(s) allowed, 7 supplied.

.. code-block:: python
   extensions = [
      ...,
      'sphinxcontrib_verilog_diagrams',
   ]
/home/tim/github/SymbiFlow/sphinxcontrib-verilog-diagrams/docs/index.rst:84: WARNING: Title underline too short.

Verilog Code Block (with license header)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/tim/github/SymbiFlow/sphinxcontrib-verilog-diagrams/docs/index.rst:106: WARNING: Title underline too short.

Verilog Code Block (without license header)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/tim/github/SymbiFlow/sphinxcontrib-verilog-diagrams/docs/index.rst:106: WARNING: Title underline too short.

Verilog Code Block (without license header)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Text in diagrams is cropped

Diagram
-------

.. hdl-diagram:: fiddlybob.v
   :type: netlistsvg
   :module: fiddlybob

fiddlybob.v:

module fiddlybob(
  input         thistextiscropped,
  input         moretextthatiscropped,
  input         moretextthatiscroppedNot,
  output        evenmoretextthatiscropped,
  output [63:0] ididnotexpectthistexttobecropped,
);
  wire  _evenmoretextthatiscropped_T_2 = ididnotexpectthistexttobecropped[0] != moretextthatiscroppedNot;
  assign evenmoretextthatiscropped = thistextiscropped & (~moretextthatiscropped | _evenmoretextthatiscropped_T_2);
endmodule

Result, cropped text:

fiddlybob

Use material theme for readthedocs

Currently the documentation is not using the material theme like other SymbiFlow projects.

I've changed my local setup to use the material theme for readthedocs, but the code block with line numbers looks awkward.

image

@mithro What do you think?

Problems installing the plugin

I'm having problems installing the plugin:

$ pip3 install --user sphinxcontrib-verilog-diagrams
ERROR: Could not find a version that satisfies the requirement sphinxcontrib-verilog-diagrams (from versions: none)
ERROR: No matching distribution found for sphinxcontrib-verilog-diagrams

ReadTheDocs has a warning that builds will fail soon

Your builds will stop working soon!
"build.image" config key is deprecated and it will be removed soon. Read our blog post to know how to migrate to new key "build.os" and ensure your project continues building successfully.

However, our .readthedocs.yml file doesn't have a build.image config key?

Weird formatting

See .. verilog-diagram and .. no-license.

Screenshot from 2020-06-24 10-25-51

These should probably link to the examples and stuff.

Add license header to top of all code files

See https://opensource.google/docs/releasing/licenses/

Put the following license header at the top;

Copyright 2020 The SymbiFlow Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Usage of -compat-int on yosys should depend on its version

#13 did not account for the fact that older versions of yosys do not have the -compat-int option for write_json. This causes this extension to fail when an older version of yosys is used (in particular the version of yosys currently present on conda does not have this option).

The version of yosys should be checked to determine whether the -compat_int options should be added to write_json.

YosysHQ/yosys@20ce411 is the commit that introduced this option.

Add support for multiple source files in directive

Currently only a single source file can be selected. It would be useful to have support for multiple source files.

Like:

.. hdl-diagram:: file.v file2.v file3.v
   :type: XXXXX
   :module: XXXX
   :skin: XXXX
   :yosys_script: XXXX
   :flatten:

Convert README.md into README.rst

rst documentation format is used heavily in the rest of this module and this module adds directives to rst. It probably makes sense for the README to also be in rst format too.

Build currently fails with issue around `SymbiFlow/sphinx_symbiflow_theme`

After fixing the issue around yosys no longer being found in the symbiflow conda channel the next error seems to be;

Ran pip subprocess with arguments:
[u'/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-hdl-diagrams/conda/84/bin/python', '-m', 'pip', 'install', '-U', '-r', '/home/docs/checkouts/readthedocs.org/user_builds/sphinxcontrib-hdl-diagrams/checkouts/84/tmpZZLQXZ.requirements.txt']
Pip subprocess output:
Collecting sphinx_symbiflow_theme
  Cloning http://github.com/SymbiFlow/sphinx_symbiflow_theme.git (to revision master) to /tmp/pip-install-m16aspc3/sphinx-symbiflow-theme_91a02a04c565470ca1d94cfad52b790e

Pip subprocess error:
  Running command git clone --filter=blob:none --quiet http://github.com/SymbiFlow/sphinx_symbiflow_theme.git /tmp/pip-install-m16aspc3/sphinx-symbiflow-theme_91a02a04c565470ca1d94cfad52b790e
  warning: redirecting to https://github.com/SymbiFlow/sphinx_symbiflow_theme.git/
  WARNING: Did not find branch or tag 'master', assuming revision or ref.
  Running command git checkout -q master
  error: pathspec 'master' did not match any file(s) known to git.
  error: subprocess-exited-with-error
  
  × git checkout -q master did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× git checkout -q master did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.