DESCRIPTION = "CoreOS Documentation"
SECTION = "devtool"
LICENSE = "CLOSED"
PV = "0.0.1+git${METADATA_REVISION}"

# The documentation is embedded inside the CoreOS repository structure, so we
# use externsrc to built it
inherit externalsrc
EXTERNALSRC := "${COREOS_ROOT}/documentation"

# This recipe only produce an HTML output, so we need to tell bitbake that it's
# doesn't depends on the target architecture
inherit allarch

# By default bitbake has the host native python3 in the path, not the one built
# by bitbake, but we can change that by ihneriting python3native
inherit python3native

# This recipes doesn't need a compiler, so we prevent the base.bbclass to add
# the default set of deps by settings the following variable to 1:
INHIBIT_DEFAULT_DEPS = "1"

DEPENDS += "python3-sphinx-native python3-sphinx-rtd-theme-native"

do_compile() {
	python3 -m sphinx.cmd.build -b html ${S} ${B}
}

# Ensure the doc is in the coreos-doc package and not in coreos-doc-doc
FILES:${PN} += "${docdir}/coreos"
PACKAGES:remove = "${PN}-doc"
do_install() {
	install -d ${D}${docdir}
	cp --no-preserve=ownership -r ${B} ${D}${docdir}/coreos
}

# Deploy to build/tmp/deploy/documentation
do_deploy() {
	rm -rf ${DEPLOY_DIR}/documentation
	cp --no-preserve=ownership -r ${B} ${DEPLOY_DIR}/documentation
}

addtask deploy after do_compile
