# -*- 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
python.add_dependencies no

name                py-htmldocs
python.versions     27 35 36 37 38 39 310
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.15 }
    if {${python.version} == 37} { version 3.7.12 }
    if {${python.version} == 38} { version 3.8.12 }
    if {${python.version} == 39} { version 3.9.8 }
    if {${python.version} == 310} { version 3.10.0 }
}

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}
    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  9fb800da26ab9d875f33d60cc2ed172e55b38a17 \
                    sha256  02a9bea40a9f17d0cea5041ad3465422e478246b90f4fb1b44b48e6f38e9697f \
                    size    6028519
    }

    if {${python.version} == 37} {
        checksums   rmd160  558eadae39156f1644036ad2ed261cbf8f5eb642 \
                    sha256  dead3859ebcf28e6ba5e4a524c41deb8cabfd47fb8b6f4206a3729963b463a8c \
                    size    6287419
    }

    if {${python.version} == 38} {
        checksums   rmd160  beb0955a49a994cd5310727b176e91b66fd45fc1 \
                    sha256  175f03235e0e6949a3054aad848f97e62994ee1783d1bcd063c4093ed608ecc3 \
                    size    6697455
    }

    if {${python.version} == 39} {
        checksums   rmd160  82ccfea24b8516e5014809cf93f6c1c88d5a2a79 \
                    sha256  d53b49b44590ee1fd13d05722d9270710936fde0febbe3843af4852706cea3d9 \
                    size    6959296
    }

    if {${python.version} == 310} {
        checksums   rmd160  ae65b2d4cef5fa53eb7792b2459999ed23e5a395 \
                    sha256  b0d9ec88feedace132366d6a6281e118d6ba7f1e9b9684125db62b9e2ea7f27c \
                    size    7263228
    }

    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
}
