# -*- 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
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.20 }
    if {${python.version} == 311} { version 3.11.15 }
    if {${python.version} == 312} { version 3.12.13 }
    if {${python.version} == 313} { version 3.13.14 }
    if {${python.version} == 314} { version 3.14.6 }
}

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  40c05c0430dcc3023ed5bd06b8eb35c5e47870aa \
                    sha256  c08ec47daa9dad1db008c1e44795a799daab89ba393718698abbcacec9d6f7c5 \
                    size    7329760
    }

    if {${python.version} == 311} {
        checksums   rmd160  1dc28b73dae0d2688997c0afccfdd970b3b2ca02 \
                    sha256  06c01a8f5734a1155479b25fe434a00f4a077b8f708e88278aa885495cba5314 \
                    size    7879534
    }

    if {${python.version} == 312} {
        checksums   rmd160  c2005564ec4a7fec3aa98357661769fe01b5ea03 \
                    sha256  481142f8c4320008e7b293e14f96b8f26940db3cc20b263d0d00abfceb358dc1 \
                    size    8433277
    }

    if {${python.version} == 313} {
        checksums   rmd160  61b9583fe063e61f24fae6a93ccdb4fab092037f \
                    sha256  ab2900e071fe3a934e8e09d0e944561e493226b39ff2cfc0ca7cdbd69eb4fa04 \
                    size    10489722
    }

    if {${python.version} == 314} {
        checksums   rmd160  f7dc1a055ab635902b82d20646b2db3e5b9c6b66 \
                    sha256  304b300fe9831bd4cb1458be5a9365dfe92bb89e061741909afd9bd88a4fa442 \
                    size    11003726
    }

    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
}
