## START: Set by rpmautospec
## (rpmautospec version 0.6.0)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 1;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

%global _description %{expand:
The LinuxDoc library contains Sphinx-doc extensions and command line tools to
extract documentation from C/C++ source file comments. Even if this project
started in context of the Linux-Kernel documentation, you can use these
extensions in common Sphinx-doc projects.}

Name:           python-linuxdoc
Version:        20231020
Release:        %{autorelease}
Summary:        Sphinx-doc extensions for sophisticated C developer


License:        AGPL-3.0-or-later
URL:            https://return42.github.io/linuxdoc/
Source0:        %{pypi_source linuxdoc}

BuildArch:      noarch

%description %_description

%package -n python3-linuxdoc
Summary:        %{summary}
BuildRequires:  python3-devel
BuildRequires:  help2man

%description -n python3-linuxdoc %_description

%prep
%autosetup -n linuxdoc-%{version}

# nothing here, empty package that gets installed in %%{python3_sitelib}
rm -rf tests

# remove shebangs
find . -type f -name "*.py" -exec sed -i '/^#![  ]*\/usr\/bin\/env.*$/ d' {} 2>/dev/null ';'

%generate_buildrequires
%pyproject_buildrequires


%build
%pyproject_wheel

%install
%pyproject_install

# generate man pages
# must be done here because binaries must be installed
for binfile in "linuxdoc.autodoc" "linuxdoc.rest" "linuxdoc.grepdoc" "linuxdoc.lintdoc" "kernel-autodoc" "kernel-doc" "kernel-grepdoc" "kernel-lintdoc"
do
    ls -lash "$RPM_BUILD_ROOT/%{_bindir}/${binfile}"
    help2man -N --version-string %{version} -h -h --no-discard-stderr "$RPM_BUILD_ROOT/%{_bindir}/${binfile}" > "${binfile}.1"
done

install -p -m 0644 -D -t "$RPM_BUILD_ROOT/%{_mandir}/man1/"  *.1

%pyproject_save_files linuxdoc

%check
# exclude sphinx < 3.0 bits, we don't have it in Fedora
%pyproject_check_import linuxdoc -e *cdomainv2*

%files -n python3-linuxdoc -f %{pyproject_files}
%doc README.rst
%{_bindir}/linuxdoc.autodoc
%{_bindir}/linuxdoc.rest
%{_bindir}/linuxdoc.grepdoc
%{_bindir}/linuxdoc.lintdoc
%{_bindir}/kernel-autodoc
%{_bindir}/kernel-doc
%{_bindir}/kernel-grepdoc
%{_bindir}/kernel-lintdoc
%{_mandir}/man1/linuxdoc.*
%{_mandir}/man1/kernel-*


%changelog
## START: Generated by rpmautospec
* Thu Jan 25 2024 Packit <hello@packit.dev> - 20231020-1
- [packit] 20231020 upstream release
- Resolves rhbz#2245262 Upstream tag: 20231020 Upstream commit: d31e0d38

* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 20230827-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Sat Sep 09 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 20230827-1
- feat: update to 20230827 (fixes rh#2226230, rh#2220311)

* Sat Sep 09 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 20230321-6
- chore(packit): init

* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 20230321-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Wed Jun 28 2023 Python Maint <python-maint@redhat.com> - 20230321-4
- Rebuilt for Python 3.12

* Sat Mar 25 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 20230321-3
- chore: check-in sources (fixes rhbz#2180396)

* Sat Mar 25 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 20230321-2
- chore: remove stale comment

* Sat Mar 25 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 20230321-1
- feat: update as per review comments
- update to latest release
- include license file
- use SPDX license
- generate and install man pages

* Sat Mar 25 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 20221127-2
- feat: ready for review

* Sat Mar 25 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 20221127-1
- init
## END: Generated by rpmautospec