[tox]
minversion = 1.6
envlist = checkniceness,checksyntax,checkdeletions,checkbuild
skipsdist = True

[testenv]
setenv =
   VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/test-requirements.txt
whitelist_externals =
  bash
  cp
  mkdir
  sed

[testenv:venv]
commands = {posargs}

[testenv:checkniceness]
commands = openstack-doc-test --check-niceness {posargs}

[testenv:checksyntax]
commands =
    openstack-doc-test --check-syntax {posargs}
    # Check that .po and .pot files are valid:
    bash -c "find doc -type f -regex '.*\.pot?' -print0|xargs -0 -n 1 msgfmt --check-format -o /dev/null"

[testenv:checkdeletions]
commands = openstack-doc-test --check-deletions {posargs}

[testenv:checkbuild]
commands = openstack-doc-test --check-build {posargs}

[testenv:publishdocs]
# Prepare all documents (except www subdir) so that they can get
# published on docs.openstack.org with just copying publish-docs/*
# over.
commands = 
  openstack-doc-test --check-build --nocreate-index --force
  # Publish install-guide and config-reference to /icehouse
  # TODO(jaegerandi): Remove these lines before we branch off an
  # icehouse branch.
  cp -a publish-docs/trunk publish-docs/icehouse
  # Replace links to /trunk with links to /icehouse/
  # This needs bash so that tox does not interpret the *
  bash -c "sed -i -e 's|/trunk/|/icehouse/|g' publish-docs/icehouse/*/atom.xml publish-docs/icehouse/*/*/*/atom.xml publish-docs/icehouse/*/*.html publish-docs/icehouse/*/*/*/*/*.html publish-docs/icehouse/*/*/*/*.html publish-docs/icehouse/*/*/*.html publish-docs/icehouse/*/*.html"

[testenv:buildlang-install]
# Run as "tox -e buildlang-install -- $LANG"
# Generatedocbook needs xml2po which cannot be installed
# in the venv. Since it's installed in the system, let's
# use sitepackages.
sitepackages=True
whitelist_externals = bash
commands =
  openstack-generate-docbook -l {posargs} -b common
  openstack-generate-docbook -l {posargs} -b glossary
  openstack-generate-docbook -l {posargs} -b user-guide
  openstack-generate-docbook -l {posargs} -b install-guide
  # tox 1.7 does not parse the following line:
  # cp doc/pom.xml generated/{posargs}/pom.xml
  # Thus replaced by the next one:
  bash ./tools/copy_pom {posargs}
  openstack-doc-test --check-build -l {posargs} --only-book install-guide --nocreate-index

[testenv:buildlang-misc]
# Run as "tox -e buildlang-misc -- $LANG"
# Generatedocbook needs xml2po which cannot be installed
# in the venv. Since it's installed in the system, let's
# use sitepackages.
sitepackages=True
whitelist_externals = bash
commands =
  openstack-generate-docbook -l {posargs} -b common
  openstack-generate-docbook -l {posargs} -b glossary
  openstack-generate-docbook -l {posargs} -b security-guide
  openstack-generate-docbook -l {posargs} -b high-availability-guide
  # tox 1.7 does not parse the following line:
  # cp doc/pom.xml generated/{posargs}/pom.xml
  # Thus replaced by the next one:
  bash ./tools/copy_pom {posargs}
  openstack-doc-test --check-build -l {posargs} --only-book security-guide --only-book high-availability-guide --nocreate-index