# -*- 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.21 }
    if {${python.version} == 311} { version 3.11.16 }
    if {${python.version} == 312} { version 3.12.14 }
    if {${python.version} == 313} { version 3.13.15 }
    if {${python.version} == 314} { version 3.14.7 }
}

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  66816eea339dbf6746066791e472c532669addfb \
                    sha256  ce31b0f22e616608658aa643236e036175452639313db72a463c573510426e5d \
                    size    7469828
    }

    if {${python.version} == 311} {
        checksums   rmd160  737c4575cf68af478f444d0a4196f7e80eb48b12 \
                    sha256  d1e8daaca02a82a03a9155097241e0a8d402b319fedb81ec947784f198046222 \
                    size    8006278
    }

    if {${python.version} == 312} {
        checksums   rmd160  ed57e1a91b863327928d2528380f1fbd31c69b4c \
                    sha256  4ceb15bdf46a9cc4d2544164984fbfd9c2fddc29025969187e482994d6e41dee \
                    size    8459739
    }

    if {${python.version} == 313} {
        checksums   rmd160  b4ad415d82313d1ba3c2b75129cc07b6d1724c1e \
                    sha256  99c7cb60c121cd41fb05abdbd0eb0400fa1efb57474fc5c136f904505b563129 \
                    size    10655948
    }

    if {${python.version} == 314} {
        checksums   rmd160  a0cfcb503884ac4a2c733722ce299d172c6e6a02 \
                    sha256  d484b784ec35c5776c5ff55f81fa984b5251a38b532b24bb00e43148bd73ffe9 \
                    size    11177897
    }

    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
}
