Git Product home page Git Product logo

sphinxcontrib-wavedrom's Introduction

sphinxcontrib-yowasp-wavedrom

This Sphinx extension allows embedding WaveDrom waveform, bitfield, and circuit diagrams into Sphinx documents.

This extension uses the YoWASP WaveDrom package to ensure that diagrams are rendered exactly the same as in the WaveDrom editor, without having to follow a decision tree for configuration, without requiring any additional tools to be installed on the system used to build documentation, without requiring any native dependencies to be installed on that system, without requiring JavaScript for browsing documentation, and without slowing down the Sphinx build process. It also reports syntax and semantic errors with accurate source locations.

WaveJSON diagram descriptions are always converted into SVG files; only the HTML builder is supported at the moment. Make sure to follow the instructions in the color schemes section!

Usage

This extension provides only one directive, wavedrom. Its argument is the base name, without extension, of the generated image file (in <output directory>/<document directory>/_images/; which must be unique for that document directory), and its contents is the raw WaveJSON file that can be copied to or from the editor. For example:

.. wavedrom:: clk_and_data

    {"signal": [
        {"name": "clk",  "wave": "n..."},
        {"name": "data", "wave": "01.0"}
    ]}

This extension also accepts WaveJSON files in the more human-friendly JSON5 format:

.. wavedrom:: clk_and_data

    {signal: [
        {name: 'clk',  wave: 'n...'},
        // a single pulse
        {name: 'data', wave: '01.0'},
    ]}

Additional examples are available in the test suite, as well as the corresponding rendered output.

Color schemes

By default, the diagrams are responsive to the preferred color scheme as provided by the user agent. This is usually not quite the desired behavior, and can make diagrams unreadable unless the extension is integrated with the chosen Sphinx theme.

For Sphinx themes that only have a light variant, e.g. the Read the Docs theme, the following custom CSS should be used:

img.wavedrom { color-scheme: light; }

For Sphinx themes that have a light variant and a dark variant and a button that switches between them, e.g. the Furo theme, the following custom CSS may be used as a starting point:

:root[data-theme="light"] { img.wavedrom { color-scheme: light; } }
:root[data-theme="dark"] { img.wavedrom { color-scheme: dark; } }

It may have to be adjusted to accommodate the particular mechanism the theme is using to keep track of the dynamically selected color scheme preference.

For Sphinx themes that have a light variant and a dark variant and do not have a button to switch between them (i.e. the user agent preference is always followed), the default behavior is sufficient.

Configuration

The extension recognizes these configuration variables in conf.py:

# Default skin for waveforms. If `json["config"]["skin"]` is not set in the directive,
# it defaults to the value of this variable. Does not affect bit fields or circuits.
yowasp_wavedrom_skin = "default"

License

This project is distributed under the terms of the MIT license.

sphinxcontrib-wavedrom's People

Contributors

whitequark avatar

Stargazers

Andrew Sutherland avatar Jevin Sweval avatar Florian Humblot avatar Luke Granger-Brown avatar Fan Jiang avatar Val Packett avatar

Watchers

 avatar Jevin Sweval avatar

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.