### Install ixbrlparse using pip Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/index.md Install the ixbrlparse module from PyPI using pip. Ensure you have Python and pip installed. ```bash pip install ixbrlparse ``` -------------------------------- ### Setup.py Entry Point for Plugin Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/plugins.md Configure your plugin's `setup.py` file to include an entry point for `ixbrlparse`. This allows `ixbrlparse` to discover and load your plugin when it is installed. ```python from setuptools import setup setup( name="ixbrlparse-dateplugin", install_requires="ixbrlparse", entry_points={"ixbrlparse": ["dateplugin = ixbrlparse_dateplugin"]}, py_modules=["ixbrlparse_dateplugin"], ) ``` -------------------------------- ### Run iXBRL Parser with uv Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/command-line.md Use the 'uvx' command to run the iXBRL parser without installation, useful for quick executions or environments where installation is not desired. ```bash uvx ixbrlparse example_file.html ``` -------------------------------- ### Run Style Linting Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/development.md Check the code for style guide violations and identify necessary formatting changes. ```bash hatch run lint:style ``` -------------------------------- ### Define Custom iXBRL Format Class Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/plugins.md Create a new format class by subclassing `ixbrlparse.ixbrlFormat`. Implement `format_names` to specify the iXBRL format names and `parse_value` to convert the raw string value to a Python object. This example defines a formatter for ISO dates. ```python import ixbrlparse import datetime class ixtParseIsoDate(ixbrlparse.ixbrlFormat): format_names = ("isodateformat") def parse_value(self, value): return datetime.datetime.strptime(value, "%Y-%m-%d").astimezone().date() ``` -------------------------------- ### Extend Existing iXBRL Format Class Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/plugins.md Override an existing format by subclassing the original format class and extending its attributes. This example extends `ixtDateDayMonthYear` to include additional date formats. ```python from ixbrlparse.components.formats import ixtDateDayMonthYear from ixbrlparse import hookimpl from ixbrlparse.ixbrlFormat class ixtDateDayMonthYearExtended(ixtDateDayMonthYear): date_format = (*ixtDateDayMonthYear.date_format, "%d-%b-%Y", "%d-%b-%y") @hookimpl def ixbrl_add_formats(self) -> list[type[ixbrlFormat]]: return [ixtDateDayMonthYearExtended] ``` -------------------------------- ### Pyproject.toml Entry Point for Plugin Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/plugins.md Configure your plugin's `pyproject.toml` file to include an entry point for `ixbrlparse` under the `[project.entry-points.ixbrlparse]` section. This is an alternative to using `setup.py` for defining entry points. ```toml [project.entry-points.ixbrlparse] dateplugin = "ixbrlparse_dateplugin" ``` -------------------------------- ### Build and Publish to PyPI Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/development.md Build the project distribution packages and publish them to the Python Package Index (PyPI). Remember to tag your release. ```bash hatch build hatch publish git tag v git push origin v ``` -------------------------------- ### Run Autoformatting Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/development.md Automatically format the code according to project style guidelines. This should be run before committing changes. ```bash hatch run lint:fmt ``` -------------------------------- ### Initialize and parse iXBRL Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/python-module.md Initialize the parser using a file handle or a string wrapped in io.StringIO. ```python with open('sample_ixbrl.html', encoding="utf8") as a: x = IXBRL(a) ``` ```python import io from ixbrlparse import IXBRL content = '''''' x = IXBRL(io.StringIO(content)) ``` -------------------------------- ### Display iXBRL Parser Help and Options Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/command-line.md Access the help message to view all available command-line options for the iXBRL parser. This includes options for specifying output files, formats, and fields. ```bash python -m ixbrlparse -h ``` -------------------------------- ### Run All Linting Checks Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/development.md Execute all configured linting and formatting checks simultaneously to ensure code quality and consistency. ```bash hatch run lint:all ``` -------------------------------- ### Generate HTML Test Coverage Report Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/development.md Run tests and generate an interactive HTML report detailing test coverage, highlighting areas needing attention. ```bash hatch run cov-html ``` -------------------------------- ### Import IXBRL class Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/python-module.md Import the primary class required for parsing iXBRL files. ```python from ixbrlparse import IXBRL ``` -------------------------------- ### Generate Test Coverage Report Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/development.md Run tests and generate a coverage report to identify untested code sections. ```bash hatch run cov ``` -------------------------------- ### Run tests with pytest Source: https://github.com/kanedata/ixbrl-parse/blob/main/README.md Execute the test suite using pytest. This command is used for verifying the functionality of the ixbrlparse module during development. ```bash hatch run test ``` ```bash pip install -e .[test] python -m pytest tests ``` -------------------------------- ### Run Tests with Pytest Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/development.md Execute all project tests using pytest via the hatch command. ```bash hatch run test ``` -------------------------------- ### Hook into ixbrlparse to Add Formats Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/plugins.md Implement the `ixbrl_add_formats` function decorated with `@ixbrlparse.hookimpl` to register your custom format classes with ixbrlparse. This function should return a list of your new format classes. ```python @ixbrlparse.hookimpl def ixbrl_add_formats(): return [ixtParseIsoDate] ``` -------------------------------- ### Run Typing Checks Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/development.md Perform static type checking on the project code to catch potential type-related errors. ```bash hatch run lint:typing ``` -------------------------------- ### Format code with Ruff Source: https://github.com/kanedata/ixbrl-parse/blob/main/README.md Automatically format the code using Ruff. This command applies code style and formatting rules to ensure consistency. ```bash hatch run lint:fmt ``` ```bash pip install -e .[lint] ruff format . ruff check --fix . ``` -------------------------------- ### IXBRL Context Component Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/reference.md Details on the ixbrlContext component for managing IXBRL context information. ```APIDOC ## IXBRL Context Component ### Description Manages context information within IXBRL documents. ### Class `src.ixbrlparse.components.context.ixbrlContext` ``` -------------------------------- ### IXBRL Core Component Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/reference.md Details about the main IXBRL parsing class. ```APIDOC ## IXBRL Core Component ### Description Provides the main interface for parsing IXBRL documents. ### Class `src.ixbrlparse.core.IXBRL` ``` -------------------------------- ### Check code style with Ruff Source: https://github.com/kanedata/ixbrl-parse/blob/main/README.md Check the code style and formatting using Ruff. This command identifies any style violations without automatically fixing them. ```bash hatch run lint:style ``` ```bash pip install -e .[lint] ruff check . ruff format --check --diff . ``` -------------------------------- ### Run iXBRL Parser Directly Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/command-line.md Execute the iXBRL parser module directly from the command line to extract data from an iXBRL file. This is the primary method for processing files. ```bash ixbrlparse example_file.html ``` ```bash python -m ixbrlparse example_file.html ``` -------------------------------- ### Access contexts and units Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/python-module.md Retrieve the contexts and units dictionaries stored within the parsed object. ```python print(x.contexts) # { # "cfwd_2018_03_31": ixbrlContext( # id="cfwd_2018_03_31", # entity="0123456", # company number # segments=[], # used for hypercubes # instant="2018-03-31", # startdate=None, # used for periods # enddate=None, # used for periods # ), # .... # } ``` ```python print(x.units) # { # "GBP": "ISO4107:GBP" # "shares": "shares" # } ``` -------------------------------- ### Hook into ixbrlparse with Custom Specname Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/plugins.md Alternatively, you can specify a `specname` for the hook implementation if you do not wish to use the default `ixbrl_add_formats` function name. This allows for more flexibility in naming your hook functions. ```python @ixbrlparse.hookimpl(specname="ixbrl_add_formats") def add_new_ixbrl_formats(): return [ixtParseIsoDate] ``` -------------------------------- ### IXBRL Format Component Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/reference.md Information regarding the ixbrlFormat component for handling IXBRL data formats. ```APIDOC ## IXBRL Format Component ### Description Handles the different formats within IXBRL data. ### Class `src.ixbrlparse.components._base.ixbrlFormat` ``` -------------------------------- ### Run typing checks with mypy Source: https://github.com/kanedata/ixbrl-parse/blob/main/README.md Perform static type checking using mypy to ensure type consistency and catch potential type errors in the codebase. This command is part of the linting process. ```bash hatch run lint:typing ``` ```bash pip install -e .[lint] mypy --install-types --non-interactive src/ixbrlparse tests ``` -------------------------------- ### IXBRL Numeric Component Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/reference.md Details on the ixbrlNumeric component for parsing numeric IXBRL facts. ```APIDOC ## IXBRL Numeric Component ### Description Parses and handles numeric facts in IXBRL data. ### Class `src.ixbrlparse.components.numeric.ixbrlNumeric` ``` -------------------------------- ### IXBRL Non-Numeric Component Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/reference.md Information about the ixbrlNonNumeric component for parsing non-numeric IXBRL facts. ```APIDOC ## IXBRL Non-Numeric Component ### Description Parses and handles non-numeric facts in IXBRL data. ### Class `src.ixbrlparse.components.nonnumeric.ixbrlNonNumeric` ``` -------------------------------- ### Handle parsing errors Source: https://github.com/kanedata/ixbrl-parse/blob/main/docs/python-module.md Suppress exceptions during parsing by setting raise_on_error to False and accessing the errors attribute. ```python with open('sample_ixbrl.html', encoding="utf8") as a: x = IXBRL(a, raise_on_error=False) print(x.errors) # populated with any exceptions found # [ eg... # ixbrlError( # error=, # element= # ) # ] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.