# -*- 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.17 }
    if {${python.version} == 38} { version 3.8.17 }
    if {${python.version} == 39} { version 3.9.17 }
    if {${python.version} == 310} { version 3.10.12 }
    if {${python.version} == 311} { version 3.11.4 }
}

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/
archive_sites

# No need to use BW from mirrors to download these; truly just an extract & mv
archive_sites

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  bd9a72a9a39d7310b7893f96fab6a46fd71ea398 \
                    sha256  c7a14f1fd990476e9b06d3163ebad26c6c5592c8a4cc6d1e98a25048bc95ec08 \
                    size    6296352
    }

    if {${python.version} == 38} {
        checksums   rmd160  56963864e26294603ed06cc2f0396004fdac4b67 \
                    sha256  1b3a54ee845229cda18eaf816c32193034099920830bf2c33e0429b9f6271bbc \
                    size    6737444
    }

    if {${python.version} == 39} {
        checksums   rmd160  5995de03377e816165347a3eef409c84807a5080 \
                    sha256  2f275406d1f17c213a428d3757e3d672c77f695484f2ebfc3fb70f4f6577d7d0 \
                    size    7021842
    }

    if {${python.version} == 310} {
        checksums   rmd160  84c5ee0d231643326509538a2ef945e01edd3a86 \
                    sha256  fb524d763a8c050986a0fe50f3d9203faa67f026a955b2215da42540e23cd9c9 \
                    size    7433462
    }

    if {${python.version} == 311} {
        checksums   rmd160  955a3cf9cbb38ad4333bef0e8b6c601171180246 \
                    sha256  639cd8c900e387eb0936cfc3a4152a8c8e3ace486b40efe31cbaa27f286fb361 \
                    size    7831799
    }

    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
}
