devana
Subpackages
- devana.code_generation
- Subpackages
- devana.code_generation.printers
- Subpackages
- devana.code_generation.printers.default
- devana.code_generation.printers.default.attributeprinter
- devana.code_generation.printers.default.basictypeprinter
- devana.code_generation.printers.default.classprinter
- devana.code_generation.printers.default.commentprinter
- devana.code_generation.printers.default.defaultprinter
- devana.code_generation.printers.default.enumprinter
- devana.code_generation.printers.default.externcprinter
- devana.code_generation.printers.default.fileprinter
- devana.code_generation.printers.default.functionprinter
- devana.code_generation.printers.default.functiontypeprinter
- devana.code_generation.printers.default.namespaceprinter
- devana.code_generation.printers.default.stubtypeprinter
- devana.code_generation.printers.default.templateparameterprinter
- devana.code_generation.printers.default.typedefprinter
- devana.code_generation.printers.default.typeexpressionprinter
- devana.code_generation.printers.default.unionprinter
- devana.code_generation.printers.default.usingnamespaceprinter
- devana.code_generation.printers.default.usingprinter
- devana.code_generation.printers.default.utilityprinters
- devana.code_generation.printers.default.variableprinter
- devana.code_generation.printers.default
- devana.code_generation.printers.codeprinter
- devana.code_generation.printers.configuration
- devana.code_generation.printers.dispatcherinjectable
- devana.code_generation.printers.formatter
- devana.code_generation.printers.icodeprinter
- Subpackages
- devana.code_generation.printers
- devana.code_generation.stubtype
- Subpackages
- devana.preprocessing
- Subpackages
- devana.preprocessing.components
- Subpackages
- devana.preprocessing.components.extractors
- devana.preprocessing.components.property
- Subpackages
- devana.preprocessing.components.property.parsers
- devana.preprocessing.components.property.parsers.attributeparser
- devana.preprocessing.components.property.parsers.configuration
- devana.preprocessing.components.property.parsers.descriptions
- devana.preprocessing.components.property.parsers.parser
- devana.preprocessing.components.property.parsers.result
- devana.preprocessing.components.property.parsers.types
- devana.preprocessing.components.property.parsers
- Subpackages
- Subpackages
- devana.preprocessing.components
- devana.preprocessing.preprocessor
- Subpackages
- devana.syntax_abstraction
- Subpackages
- devana.syntax_abstraction.attribute
- devana.syntax_abstraction.classinfo
- devana.syntax_abstraction.codelocation
- devana.syntax_abstraction.codepiece
- devana.syntax_abstraction.comment
- devana.syntax_abstraction.enuminfo
- devana.syntax_abstraction.externc
- devana.syntax_abstraction.functioninfo
- devana.syntax_abstraction.functiontype
- devana.syntax_abstraction.namespaceinfo
- devana.syntax_abstraction.syntax
- devana.syntax_abstraction.templateinfo
- devana.syntax_abstraction.typedefinfo
- devana.syntax_abstraction.typeexpression
- devana.syntax_abstraction.unioninfo
- devana.syntax_abstraction.using
- devana.syntax_abstraction.usingnamespace
- devana.syntax_abstraction.variable
- devana.utility
devana.configuration
- class CommentsParsing(accumulate=True, unpinned_comments_allowed=False, deep_parsing=False, remove_blank_lines=True, remove_asterisks=True)[source]
Bases:
IValidateConfig
The class defines how and how extensively the parsing of comments in the code is performed.
- accumulate: bool = True
Setting that defines whether consecutive C ++ style one-line comments starting with ‘//’ will be combined into a single collective instance.
- deep_parsing: bool = False
Defines parsing of additional content, e.g. comments to function arguments.
- remove_asterisks: bool = True
Removal of leading ‘*’ characters from text parsing and subsequent whitespace.
- remove_blank_lines: bool = True
If the first and last lines are empty (after initial processing by other rules) they will be deleted.
- unpinned_comments_allowed: bool = False
Specifies whether to parse or omit comments that are not attached to the code (they do not precede classes, functions, type definitions, class fields, methods, etc.). This does not affect the parsing of the file preamble.
- class Configuration(parsing=<factory>, logger=<factory>)[source]
Bases:
IValidateConfig
Main configuration.
- logger: <module 'logging' from '/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/logging/__init__.py'>
Currently used standard logger instance.
- parsing: ParsingConfiguration
Configuring the parsing of C ++ files, this is how the C ++ code will be transformed into the appropriate python classes instances.
- class IValidateConfig[source]
Bases:
ABC
Every sub-config should implement this interface to provide cohesion and implementation check.
- class IncludesSet(directories=<factory>)[source]
Bases:
IValidateConfig
A set of directories containing header files.
- directories: List[Path]
- class LanguageStandard(value)[source]
Bases:
Enum
Defines, according to the rules, which language version the parsing of files will take place.
- CPP_03 = <devana.configuration.LanguageStandard.LanguageStandardData object>
- CPP_11 = <devana.configuration.LanguageStandard.LanguageStandardData object>
- CPP_17 = <devana.configuration.LanguageStandard.LanguageStandardData object>
- CPP_20 = <devana.configuration.LanguageStandard.LanguageStandardData object>
- CPP_23 = <devana.configuration.LanguageStandard.LanguageStandardData object>
- CPP_98 = <devana.configuration.LanguageStandard.LanguageStandardData object>
- C_11 = <devana.configuration.LanguageStandard.LanguageStandardData object>
- C_17 = <devana.configuration.LanguageStandard.LanguageStandardData object>
- C_89 = <devana.configuration.LanguageStandard.LanguageStandardData object>
- C_99 = <devana.configuration.LanguageStandard.LanguageStandardData object>
- class ParsingConfiguration(comments=<factory>, language_version=<factory>, error_strategy=<factory>, standard_library=<factory>, libraries=<factory>, compiler_commands=<factory>, file_by_file_parsing=False)[source]
Bases:
IValidateConfig
Code parser configuration.
- comments: CommentsParsing
Comments parsing settings.
- compiler_commands: List[str]
Allows you to use any valid clang commands.
- error_strategy: ParsingErrorPolicy
Behavior when non-parsable elements are detected.
- file_by_file_parsing: bool = False
If true, it does not load all files into memory and builds a full type lexicon for all given files. Instead, it parses files about one another, treating other files as external dependencies. This is a less powerful solution but more economical in terms of RAM. When working with larger projects, we recommend creating multiple modules used sequentially, containing a small slice of local context instead of this option.
- language_version: LanguageStandard
C or C++ standard version.
- libraries: IncludesSet
Library search directories. It can contain both normal paths to directories, header paths that will support parsing, and paths to the location of an external library that will not be parsed within the module.
- standard_library: StandardLibraryConfiguration
How to provide the language standard library.
- class ParsingErrorPolicy(value)[source]
Bases:
Enum
Rules for dealing with errors when parsing.
- ABORT = 3
Throw exception.
- IGNORE = 1
Ignore all errors.
- LOG = 2
Only log error.
- class StandardLibraryConfiguration(mode=<factory>, path=None)[source]
Bases:
IValidateConfig
Configuration of std usage.
- mode: StandardLibraryMode
Delivery mode
- path: Optional[Path] = None
Path for custom standard library, if any.
- class StandardLibraryMode(value)[source]
Bases:
Enum
C/C++ Standard Library delivery mode.
- CUSTOM = 4
Use custom std Library provided by path.
- DEVANA_CLANG = 3
Library shipped with Devan. Recommended choice for Linux platform.
- NONE = 1
Disable standard library delivery.
- PLATFORM = 2
Library provided by the default compiler on your platform, if any are installed.
Devana is a python tool that make it easy to parsing, format, transform and generate C++ (or C) code. This tool uses libclang to parse the code. Fundamental problems, bugs and missing features of libclang are fixed in Devann’s internal code.
Please note that Devana focuses on the header-level code e.g. class and functions definitions, templates resolving, typedefs and includes. Control statements, arithmetics operations etc. (pure body of functions) are supported as access to raw string field “body”. It is planned to introduce more control over this type of code in future versions. Devana is still under development.