Giter Club home page Giter Club logo

sphinx-graph's Introduction

Sphinx Graph

codecov CI sponsor Documentation Status

'Sphinx-Graph' is a plain-text, VCS-friendly, requirements management tool.

With Sphinx-Graph you define relationships between items in a document. These items form a directed acyclic graph (DAG). The extension-

  • checks for cyclic references
  • populates items with links to their 'neighbours'
  • (optionally) tracks a hash of each item to trigger reviews when any parents change

Sphinx Graph is heavily inspired by Sphinx-Needs. Sphinx-Graph started life as a proof of concept refactor of Sphinx-Needs using modern python and strict type checking.

  • Sphinx-Needs is the full-featured, grand-daddy of Sphinx-Graph
  • By comparison, Sphinx-Graph is streamlined, and focuses on a much smaller feature set

Vertices

The core sphinx directive provided by this extension is a 'Vertex'. A Vertex directive can be used to define relationships between text elements.

.. vertex:: USR-001

   this is a user requirement.

   This user requirement forms the basis of derived system requirements. When it is rendered in a
   sphinx document it will be augmented with links to any child vertices.

.. vertex:: SYS-001
   :parents: USR-001

   this is system requirement of some sort.

   It is derived from a higher-level user requirement (USR-001).
   When it is rendered in a sphinx document, it will be augmented with links to its parent as well
   as any 'children'.

.. vertex:: SYS-002
   :parents: USR-001:iG91

   this is another system requirement. This time the link to USR-001 is tracking the 'fingerprint'
   of its parent.

   The fingerprint is a 4-character hash. If USR-001 is modified, then SYS-002 will fail the build
   until the fingerprint is updated (the build error provides the new fingerprint). This means that
   changing a Vertex will trigger a review of all dependent vertices.

For more information, see the docs.

or, build the local docs-

  cd docs
  poetry run make html

Was this useful? Buy me a coffee

sphinx-graph's People

Contributors

danieleades avatar dependabot[bot] avatar github-actions[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sphinx-graph's Issues

optionally enforce that vertices MUST have parents/children

there are situations where you want to enforce that a vertex has certain links. For example you may wish to enforce that system requirement is traceable to at least one user requirement, and fails validation if it doesn't.

I would image adding require_parent and require_child config options.
I would also add a way to apply this config to whole swathes of vertices, without having to manually specify it in each one.

reduce fingerprint size

the 'fingerprints' used to track changes to parent tasks are currently an alphanumeric md5 hash, truncated to 4 digits. That's probably excessive. 3 or even 2 digits is plenty, as hash collisions are unlikely (only 2 values to collide) and not thaaat critical if they do.

There are 62 alphanumeric characters, so with 2 characters the odds of collision are

1 - P(2 different numbers)
1 - (1 * 61/62)
~0.016

with 3 characters the odds are
(1 - (1 * (62^2-1) / 62^2)
~0.00026, or about 3 in 10 000

I'll leave it for now, but it's easier to change or even make configurable

Traceability matrix

add a traceability matrix feature.

A traceability matrix is used to show links and coverage from parents to children. For example, to show the links and coverage between requirements and their associated test cases.

For use in this library, this can be a bit more generic.

  • both 'parents' and 'children' can be the result of arbitrary queries
  • a 'link' need not be direct, so a link would show whether or not one node was an ancestor/descendent of another (ie. separated by multiple 'generations')
  • it's an error for one of the nodes in the 'parent' query to be a descendent of one of the nodes in the 'child' query (and vice versa)

so i'm imagining a directive like the following-

.. vertex-matrix::
    :parents: parent-query
    :children: child-query

    [parents]
    key1 = value1
   
    [children] 
    key2 = value2
    key3 = value3

where the query names are defined in the config, and key-value pairs can be injected using toml in the body of the directive.

In practice you'd have a default query with some sensible kwargs, so you'd have something like

.. vertex-matrix::

    [parents]
    type = "USR"
   
    [children] 
    type = "SYS"

or, equivalently-

.. vertex-matrix::

    parents = { type = "USR" }  
    children = { type = "SYS" }

this would output a table vaguely like the following -
image

with the results of each query being the row and column headers, and the value of each cell being determined by the relationship between the two corresponding nodes.

ensure PDF build works

the PDF output of the docs/ directory doesn't currently build. Need to figure out why, fix it, and test it in CI to ensure it doesn't get broken again

Add 'sibling' links

there are three options here

  1. add a 'see also' type feature where you can manually link related vertices and show links between them
  2. show links to literal graph 'siblings'
  3. both of the above

1. can be solved manually using normal sphinx reference tools. not sure if 2. is useful. I'll leave this on the backlog unless someone can articulate a use-case to me

Write a proper readme

update the readme

  • better description of project goals and use-cases
  • reference (deference) to sphinx-needs, the full-featured granddaddy of this project

also add a 'docs' repo to start storing proper documentation of this repo and it's features. Probably using sphinx 'autodoc'.

add 'transparent' nodes

allow nodes to be completely transparent in the built docs.

For example, so that a paragraph in a market requirements document can be treated as a 'requirement', but without breaking the flow of the document.

Glossary terms nested inside vertices don't work

Glossary terms nested inside vertices don't work. It's most obvious when using the latexpdf builder (seems to just fail silently when building html)

Exception occurred:
  File "/home/daniel.eades/Code/python/sphinx-graph/.venv/lib/python3.10/site-packages/docutils/nodes.py", line 652, in __getitem__
    return self.attributes[key]
KeyError: 'refdocname'

Improve the layout

the layouts all work, and build in both html and PDF, however there's plenty of room for improvement

add scoped tags

'scoped tags' is a concept borrowed from gitlab.

scoped tags are a special type of tag, where each 'variant' of a single tag scope is mutually exclusive. That is, a vertex may only have one tag in a given scope.

scoped tags are denoted by using a double colon

  • "P1" is a regular tag (no double colon)
  • "priority::1" is a scoped tag. The scope is "priority" and the variant is "1"
  • "type::subtype::A" is a scoped tag, but only the last double colon is considered. So the scope is "type::subtype" and the variant is "A"

scoped labels have the following semantics

  • it is an error to have two scoped labels on a vertex that have the same scope (ie "kind::usr" and "kind::sys" would be an error)
  • if you add non-scoped labels using vertex configuration then you get a union of all tags which have been added using the configuration override mechanism
  • if you add scoped labels, then the configuration override mechanism will replace existing labels with the same scope.

use cases:

  • lightweight mechanism for enforcing mutually exclusive tags. For example, it never makes sense for a vertex to have multiple priorities.

this is fine:

.. vertex:: 01
   :tags: priority::1, component.x, milestone::a

   this is a tagged vertex directive.
   the 'priority' and 'milestone' are scoped labels.
   the component is not.

this is not fine:

.. vertex:: 01
   :tags: priority::1, priority::2

   this is a tagged vertex directive.
   it has two tags with the same scope ('priority') hence this would
   fail to build.

allow vertices to contain nested headers

first noticed when creating vertices using myst parser.

Build errors are generated (and visible in the HTML output) when vertices contain headers.

#43 addressed the build errors, and the document is now generated correctly. However the layout isn't quite right. In my testing, a vertex with headers had the id and links information moved from the top of the vertex to the bottom in the rendered output.

Will need to investigate why that is happening...

see sphinx-doc/sphinx#11001

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.