# -*- 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 37 38 39 310 311
version             1.0
revision            0
license             PSF

if {$subport != $name} {
    if {${python.version} == 27} { version 2.7.18 }
    if {${python.version} == 37} { version 3.7.15 }
    if {${python.version} == 38} { version 3.8.15 }
    if {${python.version} == 39} { version 3.9.15 }
    if {${python.version} == 310} { version 3.10.8 }
    if {${python.version} == 311} { version 3.11.0 }
}

categories          lang
platforms           any
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} == 37} {
        checksums   rmd160  53dc6db1ef5e7ab088fb6a8fbaa1343c1ff39c8e \
                    sha256  d7e1659c6555212fa8f7c9e4da651fe0128ea851b0561a258c3ddd02918f35fc \
                    size    6275339
    }

    if {${python.version} == 38} {
        checksums   rmd160  d1e95ebfc0f4cc21e7bdebd5e1b3bc3b1a4a81d2 \
                    sha256  ab8a202c748ffbe413a348d8fde24515951f46cdb35a17c95e399b614a56cfa5 \
                    size    6695025
    }

    if {${python.version} == 39} {
        checksums   rmd160  ffaed2a40a93f8a4fe4e5576d80845fcace8b510 \
                    sha256  d47c63f8bd79f5fd303f121ed1195f5c8148bac1a2c7e626b94c5406a49c4fe8 \
                    size    6964615
    }

    if {${python.version} == 310} {
        checksums   rmd160  5a94b883a83b9c989805c780a63fc5ca7f6c2de4 \
                    sha256  e7860d2e13c14517dc69fda6da87003cc526ce37bb5e993d24f487f7a24b9ae9 \
                    size    7362386
    }

    if {${python.version} == 311} {
        checksums   rmd160  ac1c766d18ca7ad2f73761d4b21d68dbc499c4d8 \
                    sha256  81889d9ee5ec16f141a7e8d5b9f6a135f4c83994fdd9422d6b58faf5b45663d8 \
                    size    7663300
    }

    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
}
