commit:     d12bea98c17f10f039ebb2331353c6ea794674cf
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 23 17:03:28 2023 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Oct 23 17:03:28 2023 +0000
URL:        
https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=d12bea98

eclassdoc: output exported phases

Closes: https://bugs.gentoo.org/846503
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 src/pkgcore/ebuild/eclass.py  | 11 +++++++++++
 src/pkgcore/scripts/pmaint.py |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/pkgcore/ebuild/eclass.py b/src/pkgcore/ebuild/eclass.py
index 4612d0b33..9859f6571 100644
--- a/src/pkgcore/ebuild/eclass.py
+++ b/src/pkgcore/ebuild/eclass.py
@@ -590,6 +590,17 @@ class EclassDoc(AttrDict):
             rst.append(self.example)
             rst.append("")
 
+        raw_eclass_name = self.name[: -len(".eclass")]
+        latest_eapi = EAPI.known_eapis[sorted(EAPI.known_eapis)[-1]]
+        if exported_phases := [
+            x
+            for x in latest_eapi.phases.values()
+            if f"{raw_eclass_name}_{x}" in self.exported_function_names
+        ]:
+            rst.extend(_rst_header("-", "Exported Phases"))
+            rst.extend(f"- ``{phase}``" for phase in exported_phases)
+            rst.append("")
+
         if external_funcs := [x for x in self.functions if not x.internal]:
             rst.extend(_header_only("-", "Functions"))
             for func in external_funcs:

diff --git a/src/pkgcore/scripts/pmaint.py b/src/pkgcore/scripts/pmaint.py
index bc930cc0a..390f7b287 100644
--- a/src/pkgcore/scripts/pmaint.py
+++ b/src/pkgcore/scripts/pmaint.py
@@ -544,7 +544,7 @@ def _eclass_main(options, out, err):
             with open(
                 pjoin(options.output_dir, f"{os.path.basename(path)}.{ext}"), 
"wt"
             ) as f:
-                obj = EclassDoc(path)
+                obj = EclassDoc(path, sourced=True)
                 convert_func = getattr(obj, f"to_{options.format}")
                 f.write(convert_func())
         except ValueError as e:

Reply via email to