# -*- 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.13 }
    if {${python.version} == 314} { version 3.14.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/

# 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  47aa07f54ab482c1c52274e49b79999a1d222fe9 \
                    sha256  d29d8f9f43bfd16cb8b7edede87c215225d6b2ab67570c9fb10bf14eed3db4ec \
                    size    10439311
    }

    if {${python.version} == 314} {
        checksums   rmd160  f4cc22267bfd20f3f254d9baa6b5d6703307e983 \
                    sha256  b3e8f1565ed891104ca3dd48f2c1a641b2fe3ccc82408cc233235d68b638a62f \
                    size    10964901
    }

    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
}
