File ocaml-mdx.spec of Package ocaml-mdx

#
# spec file for package ocaml-mdx
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define build_flavor @BUILD_FLAVOR@%nil
%if "%build_flavor" == "testsuite"
%define nsuffix -testsuite
%else
%define nsuffix %nil
%endif

%define     pkg ocaml-mdx
Name:           %pkg%nsuffix
Version:        2.5.0
Release:        0
%{?ocaml_preserve_bytecode}
Summary:        Execute code blocks inside markdown files 
License:        ISC
Group:          Development/Languages/OCaml
URL:            https://opam.ocaml.org/packages/mdx
Source0:        %pkg-%version.tar.xz
BuildRequires:  ocaml-cppo
BuildRequires:  ocaml-dune >= 3.5
BuildRequires:  ocaml-rpm-macros >= 20240909
BuildRequires:  ocaml(ocaml_base_version) >= 4.08
%if 1
BuildRequires:  ocamlfind(astring)
BuildRequires:  ocamlfind(camlp-streams)
BuildRequires:  ocamlfind(cmdliner)
BuildRequires:  ocamlfind(compiler-libs)
BuildRequires:  ocamlfind(csexp)
BuildRequires:  ocamlfind(findlib.top)
BuildRequires:  ocamlfind(fmt)
BuildRequires:  ocamlfind(logs)
BuildRequires:  ocamlfind(ocaml-version)
BuildRequires:  ocamlfind(re)
BuildRequires:  ocamlfind(result)
BuildRequires:  ocamlfind(threads)
BuildRequires:  ocamlfind(unix)
%endif

%if "%build_flavor" == "testsuite"
BuildRequires:  ocamlfind(alcotest)
BuildRequires:  ocamlfind(mdx)
%endif

%description
mdx allows to execute code blocks inside markdown files. There are (currently) two sub-commands, corresponding to two modes of operations: pre-processing (ocaml-mdx pp) and tests (ocaml-mdx test).

The pre-processor mode allows to mix documentation and code, and to practice "literate programming" using markdown and OCaml.

The test mode allows to ensure that shell scripts and OCaml fragments in the documentation always stays up-to-date.

%package        devel
Summary:        Development files for %name
Group:          Development/Languages/OCaml
Requires:       %name = %version

%description    devel
The %name-devel package contains libraries and signature files for
developing applications that use %name.

%prep
%autosetup -p1 -n %pkg-%version

%build
mkdir -vp test/bin/mdx-test/expect/root-option/somedir
echo > $_/.gitignore
dune_release_pkgs='mdx'
%ocaml_dune_setup
%if "%build_flavor" == ""
%ocaml_dune_build
%endif

%install
%if "%build_flavor" == ""
%ocaml_dune_install
%ocaml_create_file_list
%endif

%if "%build_flavor" == "testsuite"
%check
test -x "$(type -P pandoc)" || dune_test_tolerate_fail='dune_test_tolerate_fail pandoc is_opensuse'
%ocaml_dune_test
%endif

%if "%build_flavor" == ""
%files -f %name.files
%_bindir/*

%files devel -f %name.files.devel

%endif

%changelog
openSUSE Build Service is sponsored by