Skip to content

Commit

Permalink
Merge pull request #568 from paulwarren-wk/multi-document-support
Browse files Browse the repository at this point in the history
Multi document support
  • Loading branch information
derekgengenbacher-wf authored Oct 24, 2023
2 parents dc8dcde + 5296e73 commit 8bc05e4
Show file tree
Hide file tree
Showing 33 changed files with 1,688 additions and 872 deletions.
121 changes: 121 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Inline XBRL Viewer architecture

This document provides developer documentation for various aspects of the
Inline XBRL Viewer.

## JSON data

The viewer relies on a block of JSON data that is embedded within the primary
XHTML file of the viewer. This avoids having to do full XBRL processing within
the viewer, and avoids the need to access the report's taxonomy from the
viewer.

The format of the JSON data is described below. Newer viewers are expected to
work correctly with data generated by an older plugin version within the same
major version, degrading new features gracefully if required.


```
{
"features": [],
"prefixes": {},
"roles": {},
"languages": {},
"sourceReports": [
{
"docSetFiles": [],
"targetReports": [
{
"localDocs": {},
"roleDefs": {},
"concepts": {},
"facts": {},
"rels": {},
}
]
}
],
"validation": [],
"filingDocuments": "foo.zip"
}
```

A viewer can contain one or more "source reports", each producing one or more
target report.

A source report is an Inline XBRL Document Set, comprising one or more Inline
XBRL Documents. A target report is the XBRL data obtained from extracting a
given target document from the source report.

Target documents are not yet supported, so at present, there will always be one
target report per source report.

### prefixes

`prefixes` is a map of namespace prefixes to namespace URIs. It is shared by
all Target Reports.

### languages


```
"languages": {
"en-us": "English (US)",
"en": "English",
"fr": "French",
},
```

A map of language codes to language labels. There should be an entry here for
every language code used by a label in a report.

### sourceReports

`sourceReports` is an array of objects of report data. Prior to multi-document
support, this property was not present, and the `docSetFiles` property, and the
properties of the objects within `targetReports` appeared at the top-level.

There is an object in this array for each separate Inline XBRL Document Set in
the viewer.

### docSetFiles

`docSetFiles` is a list of files in the document set. It is used to load other
documents in the document set into iframes in tabs in the viewer. For single
file, non-stub viewers, this property is not present.

### targetReports

An array of objects, one for each target document obtained from the enclosing
source report.

### localDocs

```
{
"filename.xsd": ["schema"],
"inline.xhtml": ["inline"],
}
```

`localDocs` is the set of XBRL files local to the filing (i.e. the Inline XBRL
files, and any extension taxonomies).

The property is used to populate a summary of the files in the filing in the
document summary panel.

## IDs and Viewer Unique IDs

The viewer requires all iXBRL facts to have `id` attributes. The Python plugin
will add `id` attributes to facts if not present. IDs are required to be unique
within an Inline XBRL Document Set, but in order to avoid collisions between IDs
in different Inline XBRL Document Sets when multiple source reports are
present, the JavaScript viewer internally uses "viewer unique IDs", which are
the `id` attribute values prefixed by the source report index (e.g `0-f1` is
`f1` in the first report). The original `id` attributes are only used to
resolve footnotes and continuation chains during the pre-process phase. Facts
are selected via the `ivids` data attribute on wrapper nodes, which uses viewer
unique IDs.


13 changes: 10 additions & 3 deletions iXBRLViewerPlugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ def iXBRLViewerCommandLineOptionExtender(parser, *args, **kwargs):
default=False,
dest="zipViewerOutput",
help="Converts the viewer output into a self contained zip")

# Force "keepOpen" to true, so that all models are retained. Needed for
# multi-instance viewers.
parser.set_defaults(keepOpen = True)

featureGroup = OptionGroup(parser, "Viewer Features",
"See viewer README for information on enabling/disabling features.")
for featureConfig in FEATURE_CONFIGS:
Expand Down Expand Up @@ -110,7 +115,9 @@ def generateViewer(
:param features: List of feature names to enable via generated JSON data.
"""
# extend XBRL-loaded run processing for this option
if cntlr.modelManager is None or cntlr.modelManager.modelXbrl is None or not cntlr.modelManager.modelXbrl.modelDocument:
if (cntlr.modelManager is None
or len(cntlr.modelManager.loadedModelXbrls) == 0
or any(not mx.modelDocument for mx in cntlr.modelManager.loadedModelXbrls)):
cntlr.addToLog("No taxonomy loaded.")
return
modelXbrl = cntlr.modelManager.modelXbrl
Expand All @@ -137,7 +144,7 @@ def generateViewer(
try:
out = saveViewerDest
if out:
viewerBuilder = IXBRLViewerBuilder(modelXbrl)
viewerBuilder = IXBRLViewerBuilder(cntlr.modelManager.loadedModelXbrls)
if features:
for feature in features:
viewerBuilder.enableFeature(feature)
Expand Down Expand Up @@ -306,7 +313,7 @@ def load_plugin_url():
'author': 'Paul Warren',
'copyright': 'Copyright :: Workiva Inc. :: 2019',
'CntlrCmdLine.Options': commandLineOptionExtender,
'CntlrCmdLine.Xbrl.Run': commandLineRun,
'CntlrCmdLine.Filing.End': commandLineRun,
'CntlrWinMain.Menu.Tools': toolsMenuExtender,
'CntlrWinMain.Xbrl.Loaded': guiRun,
}
Loading

0 comments on commit 8bc05e4

Please sign in to comment.