-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #861 from austinmatherne-wk/XT-3160
Create example validation plugin
- Loading branch information
Showing
49 changed files
with
1,590 additions
and
204 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
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
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,2 @@ | ||
DISCLOSURE_SYSTEM_2022 = "XYZ 2022" | ||
DISCLOSURE_SYSTEM_2023 = "XYZ 2023" |
10 changes: 10 additions & 0 deletions
10
arelle/examples/plugin/validate/XYZ/PluginValidationDataExtension.py
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,10 @@ | ||
""" | ||
See COPYRIGHT.md for copyright information. | ||
""" | ||
from __future__ import annotations | ||
|
||
from arelle.utils.validate.PluginValidationData import PluginValidationData | ||
|
||
|
||
class PluginValidationDataExtension(PluginValidationData): | ||
positiveFactConcepts: set[str] | None = None |
48 changes: 48 additions & 0 deletions
48
arelle/examples/plugin/validate/XYZ/ValidationPluginExtension.py
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,48 @@ | ||
""" | ||
See COPYRIGHT.md for copyright information. | ||
""" | ||
from __future__ import annotations | ||
|
||
from typing import Any | ||
|
||
from arelle.ModelDocument import LoadingException, ModelDocument | ||
from arelle.ModelXbrl import ModelXbrl | ||
from arelle.typing import TypeGetText | ||
from arelle.utils.validate.ValidationPlugin import ValidationPlugin | ||
from .PluginValidationDataExtension import PluginValidationDataExtension | ||
|
||
_: TypeGetText | ||
|
||
|
||
class ValidationPluginExtension(ValidationPlugin): | ||
def newPluginData(self) -> PluginValidationDataExtension: | ||
return PluginValidationDataExtension(self.name) | ||
|
||
def modelDocumentPullLoader( | ||
self, | ||
modelXbrl: ModelXbrl, | ||
normalizedUri: str, | ||
filepath: str, | ||
isEntry: bool, | ||
namespace: str | None, | ||
*args: Any, | ||
**kwargs: Any, | ||
) -> ModelDocument | LoadingException | None: | ||
if self.disclosureSystemFromPluginSelected(modelXbrl): | ||
return LoadingException(_("XYZ validation plugin is a template for new validation plugins and shouldn't be used directly.")) | ||
return None | ||
|
||
def modelXbrlLoadComplete( | ||
self, | ||
modelXbrl: ModelXbrl, | ||
*args: Any, | ||
**kwargs: Any, | ||
) -> None: | ||
if self.disclosureSystemFromPluginSelected(modelXbrl): | ||
if modelXbrl.modelDocument is None: | ||
modelXbrl.error( | ||
codes="XYZ.01.01", | ||
msg=_("An XBRL Report Package is required but could not be loaded"), | ||
modelObject=modelXbrl, | ||
) | ||
return None |
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,70 @@ | ||
""" | ||
See COPYRIGHT.md for copyright information. | ||
Filer Manual Guidelines: https://www.example.com/fake-xyz-filer-manual-v0.0.1.pdf | ||
""" | ||
from __future__ import annotations | ||
|
||
from pathlib import Path | ||
from typing import Any | ||
|
||
from arelle.ModelDocument import LoadingException, ModelDocument | ||
from arelle.Version import authorLabel, copyrightLabel | ||
from .ValidationPluginExtension import ValidationPluginExtension | ||
from .rules import rules01, rules02 | ||
|
||
PLUGIN_NAME = "Validate XYZ" | ||
DISCLOSURE_SYSTEM_VALIDATION_TYPE = "XYZ" | ||
|
||
|
||
validationPlugin = ValidationPluginExtension( | ||
name=PLUGIN_NAME, | ||
disclosureSystemConfigUrl=Path(__file__).parent / "resources" / "config.xml", | ||
validationTypes=[DISCLOSURE_SYSTEM_VALIDATION_TYPE], | ||
validationRuleModules=[rules01, rules02], | ||
) | ||
|
||
|
||
def disclosureSystemTypes(*args: Any, **kwargs: Any) -> tuple[tuple[str, str], ...]: | ||
return validationPlugin.disclosureSystemTypes | ||
|
||
|
||
def disclosureSystemConfigURL(*args: Any, **kwargs: Any) -> str: | ||
return validationPlugin.disclosureSystemConfigURL | ||
|
||
|
||
def modelDocumentPullLoader(*args: Any, **kwargs: Any) -> ModelDocument | LoadingException | None: | ||
return validationPlugin.modelDocumentPullLoader(*args, **kwargs) | ||
|
||
|
||
def modelXbrlLoadComplete(*args: Any, **kwargs: Any) -> None: | ||
return validationPlugin.modelXbrlLoadComplete(*args, **kwargs) | ||
|
||
|
||
def validateXbrlFinally(*args: Any, **kwargs: Any) -> None: | ||
return validationPlugin.validateXbrlFinally(*args, **kwargs) | ||
|
||
|
||
def validateXbrlDtsDocument(*args: Any, **kwargs: Any) -> None: | ||
return validationPlugin.validateXbrlDtsDocument(*args, **kwargs) | ||
|
||
|
||
def validateFinally(*args: Any, **kwargs: Any) -> None: | ||
return validationPlugin.validateFinally(*args, **kwargs) | ||
|
||
|
||
__pluginInfo__ = { | ||
"name": PLUGIN_NAME, | ||
"version": "0.0.1", | ||
"description": "Example validation plugin for the fictitious XYZ taxonomy.", | ||
"license": "Apache-2", | ||
"author": authorLabel, | ||
"copyright": copyrightLabel, | ||
"DisclosureSystem.Types": disclosureSystemTypes, | ||
"DisclosureSystem.ConfigURL": disclosureSystemConfigURL, | ||
"ModelDocument.PullLoader": modelDocumentPullLoader, | ||
"ModelXbrl.LoadComplete": modelXbrlLoadComplete, | ||
"Validate.XBRL.Finally": validateXbrlFinally, | ||
"Validate.XBRL.DTS.document": validateXbrlDtsDocument, | ||
"Validate.Finally": validateFinally, | ||
} |
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,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<DisclosureSystems | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="../../../../config/disclosuresystems.xsd"> | ||
<!-- see arelle/config/disclosuresystems.xml for full comments --> | ||
<DisclosureSystem | ||
names="XYZ 2023|XYZ-2023|xyz-2023|XYZ|xyz" | ||
description="Checks for example XYZ validation plugin for year 2023" | ||
validationType="XYZ" | ||
/> | ||
<DisclosureSystem | ||
names="XYZ 2022|XYZ-2022|xyz-2022" | ||
description="Checks for example XYZ validation plugin for year 2022" | ||
validationType="XYZ" | ||
/> | ||
</DisclosureSystems> |
Empty file.
Oops, something went wrong.