# -*- 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 310 311 312 313 314 315
version             1.0
revision            0
license             PSF

if {$subport != $name} {
    if {${python.version} == 27} { version 2.7.18 }
    if {${python.version} == 310} { version 3.10.22 }
    if {${python.version} == 311} { version 3.11.18 }
    if {${python.version} == 312} { version 3.12.16 }
    if {${python.version} == 313} { version 3.13.18 }
    if {${python.version} == 314} { version 3.14.10 }
    if {${python.version} == 315} { version 3.15.2 }
}

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/

# 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} == 310} {
        checksums   rmd160  d5f1175cd0a4d0108fb72dc106affd6c089f336e \
                    sha256  92174cf7a7e9168585eeb7b4b876fa4672f58d97a483936ae8aa0e1cd5315e7e \
                    size    7448157
    }

    if {${python.version} == 311} {
        checksums   rmd160  7c35906b21c887a966fd1f9bea6183c2d91bc17e \
                    sha256  50bd4110b4ec4301ddd120b5680a0da482506127f53fe4c6021a3f0dad70b990 \
                    size    8026271
    }

    if {${python.version} == 312} {
        checksums   rmd160  6a652226133bce49a09b070f018dc380ec3c3e4c \
                    sha256  39b635d5532be9778d9a1c1eb4e64c48ac16e74f4235be461b3f723b3387957c \
                    size    8526064
    }

    if {${python.version} == 313} {
        checksums   rmd160  8254d6662ab8ad351ffae8a1a3723c46031e1b4f \
                    sha256  0f018f28c1e0616ea450ee3d50f11d1a71b0bad3a6360ceb9406e8ef3d16dd3c \
                    size    8036553
    }

    if {${python.version} == 314} {
        checksums   rmd160  5d298575d2013dd8c038bff4f8c3050031a58604 \
                    sha256  89cab64cef8703b043d2c9e8265373ebd3df94864c3c1bc0435eda0703b2812d \
                    size    8485984
    }

    if {${python.version} == 315} {
        checksums   rmd160  866a25659dc3ecf03c006abb0a9da2aac29f56ad \
                    sha256  cd2115b9599be86c2f61e58747d692e2376bd9bd434eb86e233aea6968dc3f3e \
                    size    11520005
    }

    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
}
