# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0

PortGroup           github 1.0
PortGroup           python 1.0

github.setup        asciidoc-py asciidoc-py 10.2.1
revision            1
github.tarball_from releases
checksums           rmd160  f7a190ae21ba4664cae18915038e0cdd9eccd15f \
                    sha256  c3d9df7d0150bd8431c44bcc85fb29bc953a76b86ad3b8ccb34272208bf7ab4c \
                    size    1200113
name                asciidoc

categories          textproc
license             GPL-2+
maintainers         {cal @neverpanic} openmaintainer
description         Formatter/translator for text files to numerous formats
long_description \
    AsciiDoc is a text document format for writing short documents, \
    articles, books and UNIX man pages. AsciiDoc files can be translated to \
    HTML (with or without stylesheets), DocBook and LinuxDoc markup using \
    the asciidoc(1) command.  AsciiDoc is highly configurable: both the \
    AsciiDoc source file syntax and the backend output markups (which can be \
    almost any type of SGML/XML markup) can be customized and extended by \
    the user.

platforms           {darwin any}
supported_archs     noarch
installs_libs       no

homepage            https://asciidoc-py.github.io/

worksrcdir          ${github.author}-${github.project}-21e33ef
# Need autoconf to generate and install docs; python 1.0 PG disables configure, we can just re-enable it
use_autoreconf      yes
use_configure       yes
# The default for docdir is ${datarootdir}/doc/${PACKAGE_TARNAME}, and while
# these have the values we expect them to have in the configure script, this
# variable is left unexpanded and ${PACKAGE_TARNAME} is not defined in the
# Makefile after Makefile generation, ends up empty, and the documentation is
# installed in ${datarootdir}/doc. This is clearly a bug, but I'm not sure
# whether it is in autoconf or asciidoc.
configure.args      --docdir=${prefix}/share/doc/${name}

python.versions     313
python.default_version \
                    313
depends_build-append \
                    port:py${python.version}-setuptools
depends_lib         port:python${python.version} \
                    port:libxml2 \
                    port:libxslt \
                    port:docbook-xml-4.5 \
                    port:docbook-xsl-nons
depends_run         port:fop
depends_test        port:py${python.version}-pytest \
                    port:py${python.version}-pytest-mock
# Other runtime dependencies include dblatex, w3m and epubcheck, but those are
# rarely used and large. See #52758.

pre-configure {
    reinplace -W ${worksrcpath} \
        "s|python3|${python.bin}|g" \
        Makefile.in
}

post-build {
    system -W ${worksrcpath} "make manpages"
}

post-destroot {
    system -W ${worksrcpath} "make docs DESTDIR='${destroot}'"
    xinstall -d -m 0755 ${destroot}${prefix}/share/man/man1
    xinstall -m 0644 -W ${worksrcpath} \
        doc/a2x.1 \
        doc/asciidoc.1 \
        ${destroot}${prefix}/share/man/man1
}

test.run            yes
test.cmd            make
test.target         test
