%global _empty_manifest_terminate_build 0

Name:           python-furo
Version:        2023.05.20
Release:        1
Summary:        A clean customisable Sphinx documentation theme.

License:        MIT
URL:            https://github.com/pradyunsg/furo
Source0:        https://github.com/pradyunsg/furo/archive/%{version}/furo-%{version}.tar.gz
# Source1 and Source2 created with ./prepare_vendor.sh
Source1:        furo-%{version}-vendor.tar.xz
Source2:        furo-%{version}-vendor-licenses.txt

BuildArch:      noarch
BuildRequires:  nodejs-devel
BuildRequires:  nodejs-yarn
BuildRequires:  npm
BuildRequires:  python3-devel
BuildRequires:  python3-pytest
BuildRequires:  python3-setuptools
BuildRequires:  python3-pip
BuildRequires:  python3-wheel
BuildRequires:	python3-hatchling
BuildRequires:  python3-flit-core
BuildRequires:  python3-nodeenv
BuildRequires:  python3-sphinx-theme-builder
BuildRequires:  python3-beautifulsoup4
BuildRequires:  python3-sphinx >= 6.0
BuildRequires:  python3-sphinx-basic-ng
BuildRequires:  python3-sphinx-copybutton
BuildRequires:  python3-sphinx-design
BuildRequires:  python3-sphinx-inline-tabs
BuildRequires:  python3-pygments >= 2.7
BuildRequires:  python3-myst-parser

%global _description %{expand:
A clean customisable Sphinx documentation theme.
Furo is a Sphinx theme, which is:
- Intentionally minimal --- the most important thing is the content, not
  the scaffolding around it.
- Responsive --- adapting perfectly to the available screen space, to
  work on all sorts of devices.
- Customizable --- change the color palette, font families, logo and
  more!
- Easy to navigate --- with carefully-designed sidebar navigation and
  inter-page links.
- Good looking content --- through clear typography and well-stylized
  elements.
- Good looking search --- helps readers find what they want quickly.
- Biased for smaller docsets --- intended for smaller documentation
  sets, where presenting the entire hierarchy in the sidebar is not
  overwhelming.}


%description %_description

%package -n     python3-furo
Summary:        %{summary}

%description -n python3-furo %_description

%package        help
Summary:        Documentation for %{name}
# This project is MIT.  Other files bundled with the documentation have the
# following licenses:
# - searchindex.js: BSD-2-Clause
# - _sources/kitchen-sink/*.rst.txt: CC-BY-SA-4.0
# - _static/basic.css: BSD-2-Clause
# - _static/clipboard.min.js: MIT
# - _static/copy*: MIT
# - _static/doctools.js: BSD-2-Clause
# - _static/jquery*.js: MIT
# - _static/language_data.js: BSD-2-Clause
# - _static/pygments.css: BSD-2-Clause
# - _static/searchtools.js: BSD-2-Clause
# - _static/underscore*.js: MIT
License:        MIT AND BSD-2-Clause AND CC-BY-SA-4.0

%description    help
Documentation for %{name}.


%prep
%autosetup -p1 -n furo-%{version} -a1
cp -p %{SOURCE2} .

# Don't ship version control files
find . -name .gitignore -delete

# Substitute the installed nodejs version for the requested version
sed -i 's,^\(node-version = \)".*",\1"%{nodejs_version}",' pyproject.toml

# Use local objects.inv for intersphinx
sed -e 's|\("https://docs\.python\.org/3", \)None|\1"%{_docdir}/python3-docs/html/objects.inv"|' \
    -e 's|\("https://www\.sphinx-doc\.org/en/master", \)None|\1"%{_docdir}/python-sphinx-doc/html/objects.inv"|' \
    -i docs/conf.py

%build
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
export YARN_CACHE_FOLDER="$PWD/.package-cache"
yarn install --offline
nodeenv --node=system --prebuilt --clean-src $PWD/.nodeenv
%pyproject_build

%install
%pyproject_install

# Build documentation
CFLAGS="${CFLAGS:-${RPM_OPT_FLAGS}}" LDFLAGS="${LDFLAGS:-${RPM_LD_FLAGS}}" \
PATH="%{buildroot}%{_bindir}:$PATH" \
PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}" \
PYTHONDONTWRITEBYTECODE=1 \
%{?__pytest_addopts:PYTEST_ADDOPTS="${PYTEST_ADDOPTS:-} %{__pytest_addopts}"} \
PYTEST_XDIST_AUTO_NUM_WORKERS=%{_smp_build_ncpus} \
sphinx-build -b html docs html
rm -rf html/{.buildinfo,.doctrees}

%files -n python3-furo
%doc README.md
%license LICENSE
%{python3_sitelib}/furo
%{python3_sitelib}/furo*.dist-info/

%files help
%doc html
%license LICENSE

%changelog
* Wed Jul 12 2023 Dongxing Wang <dxwangk@isoftstone.com> - 2023.05.20-1
- Initial package
