<commit_before># -*- coding: utf-8 -*-
#
# pikepdf documentation build configuration file, created by
# sphinx-quickstart on Fri Feb 26 00:29:33 2016.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

import io
import os
import subprocess
import sys
from pathlib import Path

import toml
from pkg_resources import get_distribution

on_rtd = os.environ.get('READTHEDOCS') == 'True'
if on_rtd:
    import tempfile
    import zipfile

    import git
    import github
    import requests

    # Borrowed from https://github.com/YannickJadoul/Parselmouth/blob/master/docs/conf.py
    rtd_version = os.environ.get('READTHEDOCS_VERSION')
    branch = 'master' if rtd_version == 'latest' else rtd_version

    github_token = os.environ['GITHUB_TOKEN']
    head_sha = git.Repo(search_parent_directories=True).head.commit.hexsha
    g = github.Github()

    runs = (
        g.get_repo('pikepdf/pikepdf')
        .get_workflow('build_wheels.yml')
        .get_runs(branch=branch)
    )

    artifacts_url = next(r for r in runs if r.head_sha == head_sha).artifacts_url

    archive_download_url = next(
        artifact
        for artifact in requests.get(artifacts_url).json()['artifacts']
        if artifact['name'] == 'rtd-wheel'
    )['archive_download_url']
    artifact_bin = io.BytesIO(
        requests.get(
            archive_download_url,
            headers={'Authorization': f'token {github_token}'},
            stream=True,
        ).content
    )

    def pip(*args):
        subprocess.run([sys.executable, '-m', 'pip', *args], check=True)

    with zipfile.ZipFile(artifact_bin) as zf, tempfile.TemporaryDirectory() as tmpdir:
        assert len(zf.namelist()) == 1
        zf.extractall(tmpdir)
        pip('install', '--force-reinstall', f'{tmpdir}/{zf.namelist()[0]}')
else:
    sys.path.insert(0, os.path.abspath(os.path.join('..', 'installed')))

autodoc_mock_imports = ['libxmp']
autodoc_typehints = 'description'

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.join(os.path.abspath('.'), './_ext'))
sys.path.insert(0, os.path.join(os.path.abspath('.'), '..'))

import pikepdf  # isort:skip pylint: disable=unused-import

# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.intersphinx',
    'sphinx.ext.autosummary',
    'sphinx.ext.napoleon',
    'sphinx_issues',
    'IPython.sphinxext.ipython_console_highlighting',
    'IPython.sphinxext.ipython_directive',
    'fix_pybind11_autodoc',
]

issues_github_path = "pikepdf/pikepdf"

ipython_execlines = ['import pikepdf', 'from pikepdf import Pdf']

autosummary_generate = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

pyproject_toml = toml.load('../pyproject.toml')
toml_env = pyproject_toml['tool']['cibuildwheel']['environment']

rst_prolog = f"""
.. |pdfrm| replace:: :doc:`PDF 1.7 Reference Manual </references/resources>`
.. |qpdf-min-version| replace:: {toml_env['QPDF_MIN_VERSION']}
"""

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The encoding of source files.
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = 'pikepdf'
copyright = '2021, <NAME>'  # pylint: disable=redefined-builtin
author = '<NAME>'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.

release = get_distribution('pikepdf').version
version = '.'.join(release.split('.')[:2])

# The language for content autogenerated by Sphinx. Refer to documentation<commit_msg>docs: fix complaint about missing |qpdf-version|<commit_after># -*- coding: utf-8 -*-
#
# pikepdf documentation build configuration file, created by
# sphinx-quickstart on Fri Feb 26 00:29:33 2016.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

import io
import os
import subprocess
import sys
from pathlib import Path

import toml
from pkg_resources import get_distribution

on_rtd = os.environ.get('READTHEDOCS') == 'True'
if on_rtd:
    import tempfile
    import zipfile

    import git
    import github
    import requests

    # Borrowed from https://github.com/YannickJadoul/Parselmouth/blob/master/docs/conf.py
    rtd_version = os.environ.get('READTHEDOCS_VERSION')
    branch = 'master' if rtd_version == 'latest' else rtd_version

    github_token = os.environ['GITHUB_TOKEN']
    head_sha = git.Repo(search_parent_directories=True).head.commit.hexsha
    g = github.Github()

    runs = (
        g.get_repo('pikepdf/pikepdf')
        .get_workflow('build_wheels.yml')
        .get_runs(branch=branch)
    )

    artifacts_url = next(r for r in runs if r.head_sha == head_sha).artifacts_url

    archive_download_url = next(
        artifact
        for artifact in requests.get(artifacts_url).json()['artifacts']
        if artifact['name'] == 'rtd-wheel'
    )['archive_download_url']
    artifact_bin = io.BytesIO(
        requests.get(
            archive_download_url,
            headers={'Authorization': f'token {github_token}'},
            stream=True,
        ).content
    )

    def pip(*args):
        subprocess.run([sys.executable, '-m', 'pip', *args], check=True)

    with zipfile.ZipFile(artifact_bin) as zf, tempfile.TemporaryDirectory() as tmpdir:
        assert len(zf.namelist()) == 1
        zf.extractall(tmpdir)
        pip('install', '--force-reinstall', f'{tmpdir}/{zf.namelist()[0]}')
else:
    sys.path.insert(0, os.path.abspath(os.path.join('..', 'installed')))

autodoc_mock_imports = ['libxmp']
autodoc_typehints = 'description'

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.join(os.path.abspath('.'), './_ext'))
sys.path.insert(0, os.path.join(os.path.abspath('.'), '..'))

import pikepdf  # isort:skip pylint: disable=unused-import

# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.intersphinx',
    'sphinx.ext.autosummary',
    'sphinx.ext.napoleon',
    'sphinx_issues',
    'IPython.sphinxext.ipython_console_highlighting',
    'IPython.sphinxext.ipython_directive',
    'fix_pybind11_autodoc',
]

issues_github_path = "pikepdf/pikepdf"

ipython_execlines = ['import pikepdf', 'from pikepdf import Pdf']

autosummary_generate = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

pyproject_toml = toml.load('../pyproject.toml')
toml_env = pyproject_toml['tool']['cibuildwheel']['environment']

rst_prolog = f"""
.. |pdfrm| replace:: :doc:`PDF 1.7 Reference Manual </references/resources>`
.. |qpdf-min-version| replace:: {toml_env['QPDF_MIN_VERSION']}
.. |qpdf-version| replace:: {toml_env['QPDF_VERSION']}
"""

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The encoding of source files.
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = 'pikepdf'
copyright = '2021, <NAME>'  # pylint: disable=redefined-builtin
author = '<NAME>'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.

release = get_distribution('pikepdf').version
version = '.'.join(release.split('.')[:2])

# The language for content autogenerated by Sphinx. Refer to documentation
{'fraction_non_alphanumeric': 0.13385739592559787, 'fraction_numerical': 0.006643046944198406, 'mean_word_length': 3.7642405063291138, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '169502', 'n_tokens_mistral': 3008, 'n_tokens_neox': 2894, 'n_words': 787}