# -*- 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           python 1.0

name                py-htmldocs
python.versions     27 35 36 37 38 39
version             1.0
revision            0
license             PSF

if {$subport != $name} {
    if {${python.version} == 27} { version 2.7.18 }
    if {${python.version} == 35} { version 3.5.10 }
    if {${python.version} == 36} { version 3.6.13 }
    if {${python.version} == 37} { version 3.7.10 }
    if {${python.version} == 38} { version 3.8.8 }
    if {${python.version} == 39} { version 3.9.1 }
}

categories          lang
platforms           darwin
maintainers         {eborisch @eborisch} \
                    openmaintainer
supported_archs     noarch
installs_libs       no

use_bzip2           yes
use_configure       no

description         Local HTML documentation for Python.
long_description    ${description}
homepage            https://www.python.org/
master_sites        https://www.python.org/ftp/python/doc/

if {${name} != ${subport}} {
    description         HTML documentation for Python ${version}
    long_description    Access Python ${version} HTML docs via \
        file://${prefix}/share/doc/python${python.version}-doc/index.html

    master_sites        https://www.python.org/ftp/python/doc/${version}
    distname            python-${version}-docs-html
    set extractname     ${distname}
    depends_lib-delete  port:python${python.version}
    notes               ${long_description}

    if {${python.version} == 27} {
      checksums \
        rmd160  10120f30975fc9a4ee4f998fcffe764b5090172f \
        sha256  20445e9a571cacdd350f702f0980e4dc559b6ff81f1d69affe9b0a862fef2f0e \
        size    4634932
    }

    if {${python.version} == 35} {
        checksums   rmd160  cacdeb230a4deebe1e711a5436bf7d01b17fb2f4 \
                    sha256  44385d3fc3c35910f0c9ba77ecfc526335c149825848131ada3ad89383ef6bb0 \
                    size    5787877
    }

    if {${python.version} == 36} {
        checksums   rmd160  62c854d18f22805194a85e0d0c954bd341370015 \
                    sha256  13e36aea543d2ab55d116a2c150684214c0be37992d71aba126cdf58d342adac \
                    size    6016532
    }

    if {${python.version} == 37} {
        checksums   rmd160  a68f6dcff3e9752fae41cfd32780574bf9e1e7aa \
                    sha256  3d536895bcc8ea943330b2b91c645d0f028eb03af4abb589eb3b29a496b6de61 \
                    size    6289108
    }

    if {${python.version} == 38} {
        checksums   rmd160  4960b60dc4425fde466ace56357f320ff823d537 \
                    sha256  4490001bc4ee47d3f6f7ab1439a386dd2b6e1774b13310e8216368410ddef3d8 \
                    size    6590826
    }

    if {${python.version} == 39} {
        checksums   rmd160  172b697e3dad6da7b183124b86b4ce08f1c00db6 \
                    sha256  c56e35cd0ee8f7b7fa115b1b58572c9319c2b3e65b823c1a9155734c0a9a751a \
                    size    6806786
    }

    dist_subdir         ${name}/${revision}

    build {}

    destroot {
        set  destdocdir \
            ${destroot}${prefix}/share/doc/python${python.version}-doc
        file mkdir ${destroot}${prefix}/share/doc
        file copy ${workpath}/${extractname} ${destdocdir}
        system "chmod -R a+rX ${destdocdir}"
    }

    livecheck.url       https://www.python.org/ftp/python/doc/
    livecheck.type      regex
    livecheck.regex     ([string map {. \\.} ${python.branch}.\[0-9ap\]+])
} else {
    livecheck.type      none
}
