-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added builder *needs* to exports needs into a single json file
- Loading branch information
Showing
10 changed files
with
397 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
.. _builders: | ||
|
||
Builders | ||
======== | ||
|
||
.. _needs_builder: | ||
|
||
needs | ||
----- | ||
.. versionadded:: 0.1.30 | ||
|
||
The **needs** builder exports all found needs to a single json file. | ||
|
||
By default, the used file is called **needs.json** and is stored beside your conf.py file. | ||
This can be changed by setting :ref:`needs_file`. | ||
|
||
Usage | ||
+++++ | ||
|
||
.. code-block:: bash | ||
sphinx-build -b needs source_dir build_dir | ||
History data | ||
++++++++++++ | ||
|
||
The builder stores the needs under a version, which is taken from your conf.py. | ||
|
||
If a **needs.json** already exists and you raise the documentation version, the new version is stored beside the old | ||
version(s) inside the **needs.json**. | ||
|
||
.. hint:: | ||
If you generate and store/archive (e.g. in git) the **needs.json** file | ||
every time you raise your documentation version, you will get nice history data. | ||
|
||
Format | ||
++++++ | ||
|
||
.. code-block:: python | ||
{ | ||
"created": "2017-07-03T11:54:42.433876", | ||
"current_version": "1.5", | ||
"project": "needs test docs", | ||
"versions": { | ||
"1.0": { | ||
"created": "2017-07-03T11:54:42.433868", | ||
"needs": { | ||
"IMPL_01": { | ||
"description": "Incoming links of this spec: :need_incoming:`IMPL_01`.", | ||
"id": "IMPL_01", | ||
"links": [ | ||
"OWN_ID_123" | ||
], | ||
"status": null, | ||
"tags": [], | ||
"title": "Implementation for specification", | ||
"type": "impl", | ||
"type_name": "Implementation" | ||
} | ||
} | ||
} | ||
"1.5": { | ||
"created": "2017-07-03T16:10:31.633425", | ||
"needs": { | ||
"IMPL_01": { | ||
"description": "Incoming links", | ||
"id": "IMPL_01", | ||
"links": [ | ||
"OWN_ID_123" | ||
], | ||
"status": "closed", | ||
"tags": ["links","update"], | ||
"title": "Implementation for specification", | ||
"type": "impl", | ||
"type_name": "Implementation" | ||
} | ||
} | ||
} | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,7 @@ Content | |
directives | ||
roles | ||
configuration | ||
builders | ||
examples | ||
changelog | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
{ | ||
"created": "2017-07-03T11:54:42.433876", | ||
"current_version": "1.0", | ||
"project": "needs test docs", | ||
"versions": { | ||
"1.0": { | ||
"created": "2017-07-03T11:54:42.433868", | ||
"needs": { | ||
"IMPL_01": { | ||
"description": "Incoming links of this spec: :need_incoming:`IMPL_01`.", | ||
"id": "IMPL_01", | ||
"links": [ | ||
"OWN_ID_123" | ||
], | ||
"status": null, | ||
"tags": [], | ||
"title": "Implementation for specification", | ||
"type": "impl", | ||
"type_name": "Implementation" | ||
}, | ||
"OWN_ID_123": { | ||
"description": "Outgoing links of this spec: :need_outgoing:`OWN_ID_123`.", | ||
"id": "OWN_ID_123", | ||
"links": [ | ||
"R_F4722" | ||
], | ||
"status": null, | ||
"tags": [], | ||
"title": "Specification of a requirement", | ||
"type": "spec", | ||
"type_name": "Specification" | ||
}, | ||
"REQ_001": { | ||
"description": "This is an awesome requirement and it includes a nice title,\na given id, a tag and this text as description.", | ||
"id": "REQ_001", | ||
"links": [], | ||
"status": null, | ||
"tags": [ | ||
"example" | ||
], | ||
"title": "My first requirement", | ||
"type": "req", | ||
"type_name": "Requirement" | ||
}, | ||
"ROLES_REQ_1": { | ||
"description": "", | ||
"id": "ROLES_REQ_1", | ||
"links": [], | ||
"status": null, | ||
"tags": [], | ||
"title": "Sliced Bread", | ||
"type": "req", | ||
"type_name": "Requirement" | ||
}, | ||
"ROLES_REQ_2": { | ||
"description": "", | ||
"id": "ROLES_REQ_2", | ||
"links": [ | ||
"ROLES_REQ_1" | ||
], | ||
"status": null, | ||
"tags": [], | ||
"title": "Butter on Bread", | ||
"type": "req", | ||
"type_name": "Requirement" | ||
}, | ||
"R_22EB2": { | ||
"description": "", | ||
"id": "R_22EB2", | ||
"links": [], | ||
"status": "closed", | ||
"tags": [ | ||
"B", | ||
"filter" | ||
], | ||
"title": "Requirement B", | ||
"type": "req", | ||
"type_name": "Requirement" | ||
}, | ||
"R_2A9D0": { | ||
"description": "", | ||
"id": "R_2A9D0", | ||
"links": [], | ||
"status": "open", | ||
"tags": [ | ||
"A", | ||
"filter" | ||
], | ||
"title": "Requirement A", | ||
"type": "req", | ||
"type_name": "Requirement" | ||
}, | ||
"R_F4722": { | ||
"description": "This is my **first** requirement!!\n\n.. note:: You can use any rst code inside it :)", | ||
"id": "R_F4722", | ||
"links": [], | ||
"status": "open", | ||
"tags": [ | ||
"requirement", | ||
"test", | ||
"awesome" | ||
], | ||
"title": "My first requirement", | ||
"type": "req", | ||
"type_name": "Requirement" | ||
}, | ||
"S_01A67": { | ||
"description": "", | ||
"id": "S_01A67", | ||
"links": [], | ||
"status": "open", | ||
"tags": [ | ||
"B", | ||
"filter" | ||
], | ||
"title": "Specification B", | ||
"type": "spec", | ||
"type_name": "Specification" | ||
}, | ||
"S_503A1": { | ||
"description": "We haven't set an **ID** here, so sphinxcontrib-needs\nwill generated one for us.\n\nBut we have **set a link** to our first requirement and\nalso a *status* is given.", | ||
"id": "S_503A1", | ||
"links": [ | ||
"REQ_001" | ||
], | ||
"status": "done", | ||
"tags": [ | ||
"important", | ||
"example" | ||
], | ||
"title": "Spec for a requirement", | ||
"type": "spec", | ||
"type_name": "Specification" | ||
}, | ||
"S_D70B0": { | ||
"description": "", | ||
"id": "S_D70B0", | ||
"links": [], | ||
"status": "closed", | ||
"tags": [ | ||
"A", | ||
"filter" | ||
], | ||
"title": "Specification A", | ||
"type": "spec", | ||
"type_name": "Specification" | ||
}, | ||
"T_5CCAA": { | ||
"description": "", | ||
"id": "T_5CCAA", | ||
"links": [], | ||
"status": null, | ||
"tags": [ | ||
"awesome", | ||
"filter" | ||
], | ||
"title": "Test 1", | ||
"type": "test", | ||
"type_name": "Test Case" | ||
}, | ||
"T_C3893": { | ||
"description": "This test checks :need:`impl_01` for :need:`OWN_ID_123` inside a\nPython 2.7 environment.", | ||
"id": "T_C3893", | ||
"links": [ | ||
"OWN_ID_123", | ||
"IMPL_01" | ||
], | ||
"status": "implemented", | ||
"tags": [ | ||
"test", | ||
"user_interface", | ||
"python27" | ||
], | ||
"title": "Test for XY", | ||
"type": "test", | ||
"type_name": "Test Case" | ||
} | ||
}, | ||
"needs_amount": 13 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from sphinxcontrib.utils import NeedsList | ||
from sphinx.builders.text import TextBuilder | ||
from sphinx.util import logging | ||
# import logging | ||
|
||
|
||
class NeedsBuilder(TextBuilder): | ||
name = 'needs' | ||
format = 'json' | ||
file_suffix = '.txt' | ||
links_suffix = None | ||
|
||
def init(self): | ||
pass | ||
|
||
def write_doc(self, docname, doctree): | ||
pass | ||
|
||
def finish(self): | ||
log = logging.getLogger(__name__) | ||
needs = self.env.need_all_needs | ||
config = self.env.config | ||
version = config.version | ||
needs_list = NeedsList(config) | ||
|
||
needs_list.load_json() | ||
|
||
for key, need in needs.items(): | ||
needs_list.add_need(version, need["title"], need["id"], need["type"], need["type_name"], | ||
need["content"], need["status"], need["tags"], need["links"]) | ||
try: | ||
needs_list.write_json() | ||
except Exception as e: | ||
log.error("Error during writing json file: {0}".format(e)) | ||
else: | ||
log.info("Needs successfully exported") | ||
|
||
|
Oops, something went wrong.