Skip to content

Commit

Permalink
Update SQA extension to support creating non-functional requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
aeslaughter committed Dec 11, 2020
1 parent d5ab4f1 commit b9fd99f
Show file tree
Hide file tree
Showing 10 changed files with 424 additions and 415 deletions.
24 changes: 24 additions & 0 deletions python/MooseDocs/base/Extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,27 @@ def postWrite(self, page):
page[pages.Source]: The source object representing the content
"""
pass

def setAttribute(self, *args):
"""
Set a global attribute to be communicated across processors.
This is designed to be called from the <pre/post><Read/Tokenize/Render/Write> methods
"""
self.translator.executioner.setGlobalAttribute(*args)

def getAttribute(self, *args):
"""
Get a global attribute to be communicated across processors.
This is designed to be called from the <pre/post><Read/Tokenize/Render/Write> methods
"""
return self.translator.executioner.getGlobalAttribute(*args)

def getAttributeItems(self):
"""
Return an iterator to the global attributes to be communicated across processors.
This is designed to be called from the <pre/post><Read/Tokenize/Render/Write> methods
"""
return self.translator.executioner.getGlobalAttributeItems()
24 changes: 24 additions & 0 deletions python/MooseDocs/base/executioners.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ def __init__(self, **kwargs):
mixins.TranslatorObject.__init__(self)
self._page_objects = list()

# The get/setGlobalAttribute methods assume that self._global_attributes behaves
# like a dict(), the type should actually be updated to work in parallel, for example
# in ParallelBarrier it is a multiprocessing Manger.dict() object.
self._global_attributes = dict()

def init(self, destination):
"""Initialize the Page objects."""

Expand Down Expand Up @@ -127,6 +132,18 @@ def getPages(self):
"""Return a list of Page objects."""
return self._page_objects

def setGlobalAttribute(self, key, value):
"""Set a global attribute to be communicated across processors."""
self._global_attributes[key] = value

def getGlobalAttribute(self, key, default=None):
"""Get a global attribute that was communicated across processors."""
return self._global_attributes.get(key, default)

def getGlobalAttributeItems(self):
"""Return iterator to underlying global attribute dict."""
return self._global_attributes.items()

def execute(self, nodes, num_threads=1):
"""
Perform the translation.
Expand Down Expand Up @@ -300,6 +317,9 @@ def __init__(self, *args, **kwargs):
self._page_ast = None
self._page_result = None

self._manager = multiprocessi.Manger()
self._global_attributes = self._manager.dict()

def execute(self, nodes, num_threads=1):

n = len(self.getPages())
Expand Down Expand Up @@ -418,6 +438,7 @@ def execute(self, nodes, num_threads=1):
barrier = multiprocessing.Barrier(num_threads)
manager = multiprocessing.Manager()
page_attributes = manager.list([None]*len(self._page_objects))
self._global_attributes = manager.dict()

# Initialize the page attributes container using the existing list of Page node objects
for i in range(len(page_attributes)):
Expand Down Expand Up @@ -515,6 +536,9 @@ def __init__(self, *args, **kwargs):
self._page_ast = None
self._page_result = None

self._manager = multiprocessi.Manger()
self._global_attributes = self._manager.dict()

def execute(self, nodes, num_threads=1):

n = len(self.getPages())
Expand Down
467 changes: 258 additions & 209 deletions python/MooseDocs/extensions/sqa.py

Large diffs are not rendered by default.

29 changes: 14 additions & 15 deletions python/MooseDocs/test/content/extensions/sqa.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

## Requirements

!sqa requirements link-design=False category=MooseDocs

!sqa requirements link-design=False category=chigger

!sqa requirements link-design=False category=demo

## Verification and Validation
Expand All @@ -18,13 +14,6 @@

!sqa cross-reference category=demo


## Custom Matrix

!sqa requirements-matrix prefix=Z
- Item One
- Item Two

## Collections

### All Collections
Expand All @@ -35,10 +24,6 @@

!sqa collections category=demo items=Andrew

### Collection List

!sqa collections-list

## Types

### All Types
Expand All @@ -48,3 +33,17 @@
### Specific Type

!sqa types category=demo items=Andrew

## Custom Matrix

!sqa requirements category=custom prefix=C

## Collections

### Collection List

!sqa collections-list

### Collections

!sqa collections category=demo
18 changes: 18 additions & 0 deletions python/MooseDocs/test/custom.hit
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Tests]
[single]
requirement = "A single requirement"
design = sqa.md
test = MooseDocs/test/extensions/tests:core
[]
[group]
requirement = "A requirement with groups:"
[special]
detail = special
test = MooseDocs/test/extensions/tests:special
[]
[comment]
detail = comment
test = MooseDocs/test/extensions/tests:comment
[]
[]
[]

0 comments on commit b9fd99f

Please sign in to comment.