Blob Blame History Raw
%global forgeurl https://gitlab.gnome.org/GNOME/%{name}/
%global tag %{version}

Name:           gi-docgen
Version:        2021.7
%forgemeta
Release:        %autorelease
Summary:        Documentation tool for GObject-based libraries

# The entire source is (ASL 2.0 or GPLv3+) except:
#
# MIT:
#   - gidocgen/templates/basic/fzy.js
#
# CC0:
#   - docs/CODEOWNERS (-doc subpackage)
#   - examples/*.toml (-doc subpackage)
#   - gi-docgen.doap (not installed)
#   - gidocgen/porter.py
#   - MANIFEST.in (not installed)
#
# CC-BY:
#   - code-of-conduct.md (-doc subpackage)
#
# OFL:
#   - gidocgen/templates/basic/RedHat* (removed in prep)
#   - gidocgen/templates/basic/SourceCodePro* (removed in prep)
License:        (ASL 2.0 or GPLv3+) and MIT and CC0
URL:            %{forgeurl}
Source0:        %{forgesource}

# We are prohibited from bundling fonts, and we are prohibited from shipping
# fonts in web font formats; see
# https://docs.fedoraproject.org/en-US/packaging-guidelines/FontsPolicy/#_web_fonts.
#
# Since upstream uses *only* web fonts, we need a patch. We haven’t offered it
# upstream since upstream has no reason NOT to use web fonts.
#
# This patch removes all references to WOFF/WOFF2 font files (which we still
# must remove in %%prep) and ensures the CSS correctly references corresponding
# local system fonts.
Patch0:         %{name}-2021.6-no-web-fonts.patch

BuildArch:      noarch

BuildRequires:  python3-devel
BuildRequires:  pyproject-rpm-macros

# Documentation
BuildRequires:  make
BuildRequires:  python3dist(sphinx)
BuildRequires:  python3dist(sphinx-rtd-theme)

# Unbundling fonts:
BuildRequires:  font(redhatdisplay)
BuildRequires:  font(redhatdisplayblack)
BuildRequires:  font(redhatdisplaymedium)
BuildRequires:  font(redhattext)
BuildRequires:  font(redhattextmedium)
BuildRequires:  font(sourcecodepro)
BuildRequires:  font(sourcecodeprosemibold)

# Unbundling fonts:
Requires:       %{name}-fonts = %{version}-%{release}

# Trivial fork of https://github.com/jhawthorn/fzy.js (looks like it was
# basically just wrapped in an IIFE). Given that modification, it’s not clear
# how we could unbundle it, either downstream or with some kind of upstream
# support.
#
# It’s not clear what version was used for the fork.
Provides:       bundled(js-fzy)

%description
GI-DocGen is a document generator for GObject-based libraries. GObject is the
base type system of the GNOME project. GI-Docgen reuses the introspection data
generated by GObject-based libraries to generate the API reference of these
libraries, as well as other ancillary documentation.

GI-DocGen is not a general purpose documentation tool for C libraries.

While GI-DocGen can be used to generate API references for most GObject/C
libraries that expose introspection data, its main goal is to generate the
reference for GTK and its immediate dependencies. Any and all attempts at
making this tool more generic, or to cover more use cases, will be weighted
heavily against its primary goal.

GI-DocGen is still in development. The recommended use of GI-DocGen is to add
it as a sub-project to your Meson build system, and vendor it when releasing
dist archives.

You should not depend on a system-wide installation until GI-DocGen is declared
stable.


%package fonts
Summary:        Metapackage providing fonts for gi-docgen output
# Really, there is nothing copyrightable in this metapackage, so we give it the
# overall license of the project.
License:        (ASL 2.0 or GPLv3+)

Requires:       font(redhatdisplay)
Requires:       font(redhatdisplayblack)
Requires:       font(redhatdisplaymedium)
Requires:       font(redhattext)
Requires:       font(redhattextmedium)
Requires:       font(sourcecodepro)
Requires:       font(sourcecodeprosemibold)

%description fonts
Because web fonts from upstream are not bundled in the %{name} package,
documentation packages generated with %{name} must depend on this metapackage
to ensure the proper system fonts are present.


%package doc
Summary:        Documentation for %{name}
License:        (ASL 2.0 or GPLv3+) and CC0 and CC-BY

%description doc
Documentation for %{name}.


%generate_buildrequires
# We do not run the tests; but we add the runtime requirements as BR’s anyway
# so that the build will fail if some are not available in the distribution.
%pyproject_buildrequires -r


%prep
%autosetup -p1

# Remove all bundled fonts. See Patch0.
find . -type f \( -name '*.woff' -o -name '*.woff2' \) -print -delete


%build
%pyproject_wheel

%make_build -C docs
rm -rvf docs/_build/.buildinfo docs/_build/.doctrees


%install
%pyproject_install
%pyproject_save_files gidocgen

install -t '%{buildroot}%{_pkgdocdir}' -D -m 0644 -p \
    code-of-conduct.md \
    CONTRIBUTING.md \
    docs/CODEOWNERS \
    README.md
cp -rp docs/_build '%{buildroot}%{_pkgdocdir}/html'
cp -rp examples '%{buildroot}%{_pkgdocdir}/'


%files -f %{pyproject_files}
%license LICENSES/*.txt

%{_bindir}/%{name}
%{_mandir}/man1/%{name}.1*
# Normally, this would go in a -devel package, but there is little point in
# providing a -devel package for *just* the .pc file when there are no
# libraries or headers.
%{_datadir}/pkgconfig/%{name}.pc


%files fonts
# Empty; this is a metapackage


%files doc
%license LICENSES/*.txt
%doc %{_pkgdocdir}


%changelog
%autochangelog