Skip to content
Commits on Source (20)
......@@ -3,6 +3,14 @@ Upstream-Name: gi-docgen
Upstream-Contact: Emmanuele Bassi <ebassi@gnome.org>
Source: https://gitlab.gnome.org/ebassi/gi-docgen
Files: README.md
Copyright: 2021 GNOME Foundation
License: Apache-2.0 OR GPL-3.0-or-later
Files: CHANGES.md
Copyright: 2022 Emmanuele Bassi
License: CC0-1.0
Files: gi-docgen.pc.in
Copyright: 2021 GNOME Foundation
License: CC0-1.0
......
# Changes
All notable changes to this project will be documented in this file.
## [Unreleased]
### Added
### Changed
### Fixed
### Removed
## [2023.1] - 2023-01-06
### Added
- Use tomlib for Python >= 3.11 and tomli/toml for Python < 3.11 [!168, !172]
### Fixed
- Use the proper link fragment for interface prerequisite [#148]
......@@ -3,7 +3,7 @@
include pyproject.toml
include pytest.ini
include README.md meson.build gi-docgen.pc.in
include CHANGES.md README.md meson.build gi-docgen.pc.in
include gi-docgen.py
include .flake8
include .green
......
Metadata-Version: 2.1
Name: gi-docgen
Version: 2022.2
Version: 2023.1
Summary: Documentation tool for GObject-based libraries
Home-page: https://gitlab.gnome.org/GNOME/gi-docgen
Author: Emmanuele Bassi
......@@ -31,12 +31,6 @@ Description-Content-Type: text/markdown
License-File: LICENSES/Apache-2.0.txt
License-File: LICENSES/GPL-3.0-or-later.txt
<!--
SPDX-FileCopyrightText: 2021 GNOME Foundation
SPDX-License-Identifier: Apache-2.0 OR GPL-3.0-or-later
-->
GI-DocGen: Documentation tool for GObject-based libraries
-------------------------------------------------------------------------------
......
<!--
SPDX-FileCopyrightText: 2021 GNOME Foundation
SPDX-License-Identifier: Apache-2.0 OR GPL-3.0-or-later
-->
GI-DocGen: Documentation tool for GObject-based libraries
-------------------------------------------------------------------------------
......
Metadata-Version: 2.1
Name: gi-docgen
Version: 2022.2
Version: 2023.1
Summary: Documentation tool for GObject-based libraries
Home-page: https://gitlab.gnome.org/GNOME/gi-docgen
Author: Emmanuele Bassi
......@@ -31,12 +31,6 @@ Description-Content-Type: text/markdown
License-File: LICENSES/Apache-2.0.txt
License-File: LICENSES/GPL-3.0-or-later.txt
<!--
SPDX-FileCopyrightText: 2021 GNOME Foundation
SPDX-License-Identifier: Apache-2.0 OR GPL-3.0-or-later
-->
GI-DocGen: Documentation tool for GObject-based libraries
-------------------------------------------------------------------------------
......
.flake8
.green
CHANGES.md
CONTRIBUTING.md
MANIFEST.in
README.md
......
......@@ -2,5 +2,7 @@ Markdown>=3.2
MarkupSafe
Pygments
jinja2
toml
typogrify
[:python_version < "3.11"]
tomli
......@@ -3,13 +3,45 @@
import os
import re
import toml
toml_module = None
try:
import tomllib as toml_lib
toml_module = 'tomlib'
except ImportError:
try:
import tomli as toml_lib
toml_module = 'tomli'
except ImportError:
import toml as toml_lib
toml_module = 'toml'
from urllib.parse import urljoin
from . import core, log, utils
class TomlConfig:
"""Wrapper class for TOML loading"""
@staticmethod
def load(toml):
log.debug(f"Using TOML module: {toml_module}")
if toml_module is None:
log.error("No toml module found")
elif toml_module in ['tomlib', 'tomli']:
try:
with open(toml, "rb") as f:
return toml_lib.load(f)
except toml_lib.TOMLDecodeError as err:
log.error(f"Invalid configuration file: {toml}: {err}")
elif toml_module in ['toml']:
try:
return toml_lib.load(toml)
except toml_lib.TomlDecodeError as err:
log.error(f"Invalid configuration file: {toml}: {err}")
class GIDocConfig:
"""Load and represent the configuration for gidocgen"""
def __init__(self, config_file=None):
......@@ -17,11 +49,8 @@ class GIDocConfig:
self._config = {}
if self._config_file is not None:
try:
log.debug(f"Reading configuration file: {self._config_file}")
self._config = toml.load(self._config_file)
except toml.TomlDecodeError as err:
log.error(f"Invalid configuration file: {self._config_file}: {err}")
log.debug(f"Reading configuration file: {self._config_file}")
self._config = TomlConfig.load(self._config_file)
@property
def library(self):
......@@ -241,11 +270,8 @@ class GITemplateConfig:
self._config_file = os.path.join(templates_dir, template_name, f"{template_name}.toml")
self._config = {}
try:
log.debug(f"Reading template configuration file: {self._config_file}")
self._config = toml.load(self._config_file)
except toml.TomlDecodeError as err:
log.error(f"Invalid template configuration file: {self._config_file}: {err}")
log.debug(f"Reading template configuration file: {self._config_file}")
self._config = TomlConfig.load(self._config_file)
@property
def name(self):
......
# SPDX-FileCopyrightText: 2020 GNOME Foundation <https://gnome.org>
# SPDX-License-Identifier: Apache-2.0 OR GPL-3.0-or-later
version = "2022.2"
version = "2023.1"
......@@ -1253,6 +1253,16 @@ class TemplateInterface:
self.requires_fqtn = f"{self.requires_namespace}.{self.requires_name}"
log.debug(f"Preqrequisite for {self.fqtn}: {self.requires_fqtn}")
def prereq_link_fragment(_ns: gir.Namespace, ns: str, name: str) -> str:
if _ns.repository.find_class(name, ns) is not None:
return "class"
elif _ns.repository.find_interface(name, ns) is not None:
return "iface"
else:
log.error(f"Invalid prerequisite type {ns}.{name}")
self.requires_link_fragment = prereq_link_fragment(namespace, self.requires_namespace, self.requires_name)
self.symbol_prefix = f"{namespace.symbol_prefix[0]}_{interface.symbol_prefix}"
self.type_cname = interface.base_ctype
......
......@@ -80,7 +80,7 @@ SPDX-License-Identifier: {{ CONFIG.license }}
{% block sidebar %}
{% endblock %}
<div class="section generator">
<p>Generated by gi-docgen {{ CONFIG.generator }}</p>
<p>Generated by <a href="https://gitlab.gnome.org/GNOME/gi-docgen">gi-docgen</a> {{ CONFIG.generator }}</p>
</div>
</nav>
......
......@@ -150,10 +150,10 @@
<div class="docblock">
<p>In order to implement {{ interface.name }}, your type must inherit from
{% if interface.requires_namespace == namespace.name -%}
<a href="class.{{ interface.requires_name }}.html">
{%- if interface.requires_namespace == namespace.name -%}
<a href="{{ interface.requires_link_fragment }}.{{ interface.requires_name }}.html">
{%- else -%}
<a data-namespace="{{ interface.requires_namespace }}" data-link="class.{{ interface.requires_name }}.html" href="javascript:void(0)" class="external">
<a data-namespace="{{ interface.requires_namespace }}" data-link="{{ interface.requires_link_fragment }}.{{ interface.requires_name }}.html" href="javascript:void(0)" class="external">
{%- endif -%}
<code>{{ interface.requires_ctype }}</code></a>.</p>
</div>
......
......@@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0 OR GPL-3.0-or-later
project('gi-docgen',
version: '2022.2',
version: '2023.1',
meson_version: '>= 0.55.0',
)
......@@ -13,7 +13,6 @@ py = import('python').find_installation('python3',
'markdown',
'markupsafe',
'pygments',
'toml',
'typogrify',
],
)
......@@ -27,6 +26,26 @@ if not markdown_version.version_compare('>=3.2')
error('gi-docgen requires at least markdown >= 3.2')
endif
if py.language_version().version_compare('<3.11')
tomli_version = run_command(
py, '-c', 'import tomli; print(tomli.__version__)',
check: false,
).stdout().strip()
if tomli_version.version_compare('>=1.0')
message('Falling back to toml on Python <3.11')
else
toml_version = run_command(
py, '-c', 'import toml; print(toml.__version__)',
check: false,
).stdout().strip()
if toml_version.version_compare('>=0.10.2')
warning('Falling back to deprecated toml module; please update to tomli')
else
error('tomli 1.0 or newer required on Python 3.10 and older')
endif
endif
endif
configure_file(
input: 'gi-docgen.py',
output: 'gi-docgen',
......
......@@ -39,7 +39,7 @@ Markdown = "^3.2"
MarkupSafe = "^1"
Pygments = "^2"
Jinja2 = "^2"
toml = "^0"
tomli = { version = ">=1,<3", markers = "python_version < '3.11'" }
typogrify = "^2"
[tool.poetry.dev-dependencies]
......
......@@ -51,7 +51,7 @@ install_requires =
MarkupSafe
Pygments
jinja2
toml
tomli; python_version < '3.11'
typogrify
[options.entry_points]
......