## START: Set by rpmautospec
## (rpmautospec version 0.7.3)
## 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

Name:           novelwriter
Version:        2.6.3
Release:        %autorelease
Summary:        Plain text editor designed for writing novels

# Code is GPL-3.0-or-later, icons are CC-BY-SA-4.0
License:        GPL-3.0-or-later AND CC-BY-SA-4.0 
URL:            https://novelwriter.io/
Source:         https://github.com/vkbo/novelwriter/archive/v%{version}/novelwriter-%{version}.tar.gz

BuildArch:      noarch
BuildRequires:  adobe-source-sans-pro-fonts
BuildRequires:  hunspell-en
BuildRequires:  hunspell-en-GB
BuildRequires:  hunspell-en-US
BuildRequires:  enchant2-devel
BuildRequires:  enchant2-hunspell
BuildRequires:  enchant2-nuspell
BuildRequires:  hunspell-devel
BuildRequires:  nuspell-devel
BuildRequires:  python3-enchant
BuildRequires:  qt5-qttools-devel
BuildRequires:  qt5-qtsvg-devel
BuildRequires:  python3-devel

BuildRequires: libappstream-glib
BuildRequires: desktop-file-utils
BuildRequires: hicolor-icon-theme

# Test requirements
BuildRequires:  python3dist(pytest)
BuildRequires:  python3dist(pytest-qt)
BuildRequires:  python3dist(pytest-xvfb)
# Documentation requirements
BuildRequires:  python3dist(docutils)
BuildRequires:  python3dist(pygments)
BuildRequires:  python3dist(sphinx)
# Not packaged
#BuildRequires:  python3dist(sphinx-book-theme)
BuildRequires:  python3dist(sphinx-design)
# Not packaged
BuildRequires:  python3dist(sphinx-favicon)
BuildRequires:  python3dist(sphinx-intl)

%description
novelWriter is a plain text editor designed for writing novels assembled from
many smaller text documents. It uses a minimal formatting syntax inspired by
Markdown, and adds a meta data syntax for comments, synopsis, and
cross-referencing. It's designed to be a simple text editor that allows for
easy organisation of text and notes, using human readable text files as
storage for robustness.

The project storage is suitable for version control software, and also well
suited for file synchronisation tools. All text is saved as plain text files
with a meta data header. The core project structure is stored in a single
project XML file. Other meta data is primarily saved as JSON files.

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



%generate_buildrequires
%pyproject_buildrequires

%build
%pyproject_wheel
# Build documentation
#pushd docs
#sphinx-build source epub -b epub
#popd

%install
%pyproject_install
%pyproject_save_files novelwriter
desktop-file-install                                    \
--dir=%{buildroot}%{_datadir}/applications              \
setup/data/novelwriter.desktop
install -Dm644 setup/novelwriter.appdata.xml %{buildroot}%{_metainfodir}
install -d setup/data/hicolor %{_datadir}/icons/

%check
QT_QPA_PLATFORM=offscreen %pytest
appstream-util validate-relax --nonet %{buildroot}%{_metainfodir}/novelwriter.appdata.xml

%files -n novelwriter -f %{pyproject_files}
%license LICENSE.md
%doc README.md
%{_bindir}/novelwriter
%{buildroot}%{_datadir}/applications/novelwriter.desktop
%{buildroot}%{_metainfodir}/novelwriter.appdata.xml	
%{_datadir}/icons/hicolor/*/apps/*.png
%{_datadir}/icons/hicolor/*/apps/*.svg

%changelog
## START: Generated by rpmautospec
* Wed Mar 26 2025 John Doe <packager@example.com> - 2.6.3-1
- Uncommitted changes
## END: Generated by rpmautospec