<commit_before>"""Configuration and execution of Doxygen at the stack level.
"""

__all__ = (
    'DoxygenConfiguration', 'preprocess_package_doxygen_conf', 'run_doxygen')

from copy import deepcopy
import csv
from collections.abc import Iterable
from dataclasses import dataclass, field, fields
import itertools
import logging
import os
from pathlib import Path
import re
import subprocess
from typing import List, Tuple, Set, Any

from documenteer.utils import working_directory
from .pkgdiscovery import Package

_PATH_LIKE = (
    "EXAMPLE_PATH",
    "EXCLUDE",
    "INCLUDE_PATH",
    "@INCLUDE_PATH",
    "INPUT",
    "IMAGE_PATH",
    "GENERATE_TAGFILE"
)
"""Names of path-like Doxygen configuration tags.
"""

_BLANK_LINE_PATTERN = re.compile(r"^\s*$")
"""Regular expression for a blank line in a Doxygen configuration file.
"""

_CONFIG_PATTERN = re.compile(
    # Configuration name
    r"^\s*(?P<name>\S+)"
    # Assignment operator
    r"\s*\+?=\s*"
    # Configuration value
    r"(?P<value>.*)"
)
"""Regular expression for a Doxygen configuration file.
"""

_COMMENT_PATTERN = re.compile(r'^[ \t]*##')
"""Regular expression for comment lines in a Doxygen configuration file.
"""


@dataclass
class DoxygenConfiguration:
    """A restricted Doxygen configuration.

    Rather than accomodating arbitrary Doxygen configurations, this class
    maintains the key configurations that are required for a Doxygen build
    that is intended to be incorporated into a Sphinx build. As such, this
    configuration file may ignore some configuration values when parsing a
    raw configuration file.

    Notes
    -----
    See http://www.doxygen.nl/manual/config.html for more details about
    Doxygen configurations.
    """

    inputs: List[Path] = field(
        default_factory=list,
        metadata={
            'doxygen_tag': 'INPUT'
        }
    )
    """Individual paths to be input into the doxygen build.
    """

    excludes: List[Path] = field(
        default_factory=list,
        metadata={
            'doxygen_tag': 'EXCLUDE'
        }
    )
    """File or directory paths to be excluded from the inputs.
    """

    recursive: bool = field(
        default=True,
        metadata={
            'doxygen_tag': 'RECURSIVE'
        }
    )
    """Whether or not directories listed in `inputs` should be searched
    recursively.
    """

    file_patterns: List[str] = field(
        default_factory=lambda: ['*.h', '*.cc'],
        metadata={
            'doxygen_tag': 'FILE_PATTERNS'
        }
    )
    """File extensions to include from the directories described by `inputs`.
    """

    exclude_patterns: List[str] = field(
        default_factory=list,
        metadata={
            'doxygen_tag': 'EXCLUDE_PATTERNS'
        }
    )
    """Absolute file paths that match these patterns are excluded from the
    Doxygen build.
    """

    exclude_symbols: List[str] = field(
        default_factory=list,
        metadata={
            'doxygen_tag': 'EXCLUDE_SYMBOLS'
        }<commit_msg>Inputs is not available for cross referencing?<commit_after>"""Configuration and execution of Doxygen at the stack level.
"""

__all__ = (
    'DoxygenConfiguration', 'preprocess_package_doxygen_conf', 'run_doxygen')

from copy import deepcopy
import csv
from collections.abc import Iterable
from dataclasses import dataclass, field, fields
import itertools
import logging
import os
from pathlib import Path
import re
import subprocess
from typing import List, Tuple, Set, Any

from documenteer.utils import working_directory
from .pkgdiscovery import Package

_PATH_LIKE = (
    "EXAMPLE_PATH",
    "EXCLUDE",
    "INCLUDE_PATH",
    "@INCLUDE_PATH",
    "INPUT",
    "IMAGE_PATH",
    "GENERATE_TAGFILE"
)
"""Names of path-like Doxygen configuration tags.
"""

_BLANK_LINE_PATTERN = re.compile(r"^\s*$")
"""Regular expression for a blank line in a Doxygen configuration file.
"""

_CONFIG_PATTERN = re.compile(
    # Configuration name
    r"^\s*(?P<name>\S+)"
    # Assignment operator
    r"\s*\+?=\s*"
    # Configuration value
    r"(?P<value>.*)"
)
"""Regular expression for a Doxygen configuration file.
"""

_COMMENT_PATTERN = re.compile(r'^[ \t]*##')
"""Regular expression for comment lines in a Doxygen configuration file.
"""


@dataclass
class DoxygenConfiguration:
    """A restricted Doxygen configuration.

    Rather than accomodating arbitrary Doxygen configurations, this class
    maintains the key configurations that are required for a Doxygen build
    that is intended to be incorporated into a Sphinx build. As such, this
    configuration file may ignore some configuration values when parsing a
    raw configuration file.

    Notes
    -----
    See http://www.doxygen.nl/manual/config.html for more details about
    Doxygen configurations.
    """

    inputs: List[Path] = field(
        default_factory=list,
        metadata={
            'doxygen_tag': 'INPUT'
        }
    )
    """Individual paths to be input into the doxygen build.
    """

    excludes: List[Path] = field(
        default_factory=list,
        metadata={
            'doxygen_tag': 'EXCLUDE'
        }
    )
    """File or directory paths to be excluded from the inputs.
    """

    recursive: bool = field(
        default=True,
        metadata={
            'doxygen_tag': 'RECURSIVE'
        }
    )
    """Whether or not directories listed in ``inputs`` should be searched
    recursively.
    """

    file_patterns: List[str] = field(
        default_factory=lambda: ['*.h', '*.cc'],
        metadata={
            'doxygen_tag': 'FILE_PATTERNS'
        }
    )
    """File extensions to include from the directories described by
    ``inputs``.
    """

    exclude_patterns: List[str] = field(
        default_factory=list,
        metadata={
            'doxygen_tag': 'EXCLUDE_PATTERNS'
        }
    )
    """Absolute file paths that match these patterns are excluded from the
    Doxygen build.
    """

    exclude_symbols: List[str] = field(
        default_factory=list,
        metadata={
            'doxygen_tag': 'EXCLUDE_SYMBOLS'
        }
{'fraction_non_alphanumeric': 0.10378750614854894, 'fraction_numerical': 0.0, 'mean_word_length': 2.873015873015873, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '949851', 'n_tokens_mistral': 1844, 'n_tokens_neox': 1714, 'n_words': 554}