[gi-docgen/ebassi/deprecated-since: 1/3] gir: Improve the deprecation check
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gi-docgen/ebassi/deprecated-since: 1/3] gir: Improve the deprecation check
- Date: Mon, 31 Jan 2022 00:11:18 +0000 (UTC)
commit 273393043f0a17e842d7f16506b423630e613717
Author: Emmanuele Bassi <ebassi gnome org>
Date: Sun Jan 30 23:52:36 2022 +0000
gir: Improve the deprecation check
Deprecation annotations should have a version and a message, but neither
is mandatory.
If find a deprecation node, we explicitly mark the element as
deprecated.
gidocgen/gir/ast.py | 6 ++++--
gidocgen/gir/parser.py | 2 --
2 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/gidocgen/gir/ast.py b/gidocgen/gir/ast.py
index 5fe7fec..621c241 100644
--- a/gidocgen/gir/ast.py
+++ b/gidocgen/gir/ast.py
@@ -73,6 +73,7 @@ class Info:
self.introspectable = introspectable
self.deprecated_msg = deprecated
self.deprecated_version = deprecated_version
+ self.deprecated = deprecated is not None or deprecated_version is not None
self.version = version
self.stability = stability
self.attributes: T.Mapping[str, T.Optional[str]] = {}
@@ -135,6 +136,7 @@ class GIRElement:
"""Set the deprecation annotations for the element"""
self.info.deprecated_msg = doc
self.info.deprecated_version = since_version
+ self.info.deprecated = True
def set_attributes(self, attrs: T.Mapping[str, T.Optional[str]]) -> None:
"""Add an annotation to the symbol"""
@@ -151,9 +153,9 @@ class GIRElement:
@property
def deprecated_since(self) -> T.Optional[T.Tuple[str, str]]:
- if not self.info.deprecated_msg:
- return None
version = self.info.deprecated_version
+ if version is None:
+ return None
message = self.info.deprecated_msg
if message is None:
message = "Please do not use it in newly written code"
diff --git a/gidocgen/gir/parser.py b/gidocgen/gir/parser.py
index aa42502..ca779a2 100644
--- a/gidocgen/gir/parser.py
+++ b/gidocgen/gir/parser.py
@@ -333,8 +333,6 @@ class GirParser:
if deprecated is not None:
deprecated_since = node.attrib.get('deprecated-version')
deprecated_doc = self._maybe_parse_deprecated_doc(node)
- if deprecated_doc is None:
- deprecated_doc = ''
element.set_deprecated(deprecated_doc, deprecated_since)
def _parse_array(self, node: ET.Element) -> ast.Type:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]