Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi document support #568

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
08e84e4
Generation-side support for multi-documents.
Sep 18, 2023
730bdf9
Multi-report - WIP
Sep 19, 2023
a6b5092
Further WIP
Sep 20, 2023
8dd177a
Introduce ReportSet class
Sep 22, 2023
281339b
Fix footnotes.
Sep 23, 2023
fd1fee1
Rename iXBRLReport to XBRLReport.
Sep 23, 2023
68acbec
Fix tests.
Sep 23, 2023
da82fa5
Test fixes.
Sep 24, 2023
69229f5
Modernize code.
Sep 25, 2023
75ea6a1
Fix tests
Sep 25, 2023
b9d1437
Multi-doc support for outlines.
Sep 26, 2023
ce49877
Fix python tests.
Sep 27, 2023
c119972
Support for multi-report fact deep links.
Oct 1, 2023
8e19c56
Report set test.
Oct 1, 2023
beb15d1
Fix legacy reference to dts property.
Oct 2, 2023
151bdb7
Merge remote-tracking branch 'upstream/master' into multi-document-su…
Oct 2, 2023
1aa8ea0
Fix fact deep linking.
Oct 2, 2023
706f0db
Make anchoring detection multi-doc aware.
Oct 2, 2023
af8c506
Comments, renaming, reportSet tests
Oct 3, 2023
e82713e
Initial draft of architecture document
Oct 4, 2023
86f50e3
Split reports data into sourceReports/targetReports.
Oct 4, 2023
169b027
Add comment explaining keepOpen option.
Oct 5, 2023
74f4e0d
Remove legacy reference to dts object.
Oct 5, 2023
60a0c06
Expand description of viewer unique IDs.
Oct 6, 2023
b7097cb
Don't include report number in fragment for first report.
Oct 6, 2023
dcbfc44
Renaming/refactoring to clarify viewer unique IDs
Oct 6, 2023
74b457d
Change approach to overriding keepOpen option (needed for more recent…
Oct 6, 2023
8b9ba0b
Rename "dts" to "logger_model"
Oct 6, 2023
a5bded1
Simplify fact deep link.
Oct 6, 2023
afede45
Fix localId().
Oct 9, 2023
46886af
Fix tests.
Oct 9, 2023
e9f066a
Fix approach to setting "keepOpen"
Oct 9, 2023
5296e73
Rename getUsedPrefixes
Oct 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": {
paulwarren-wk marked this conversation as resolved.
Show resolved Hide resolved
"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