- name: Emit pandoc version
  command: "pandoc --version"

- name: Add destination to parameters
  ansible.builtin.set_fact:
    convert_params: "{{ convert_params }} --dest {{ dest }}"
  when: "dest is defined"

- name: Add title to parameters
  ansible.builtin.set_fact:
    convert_params: "{{ convert_params }} --title '{{ doc_title }}'"
  when: "doc_title is defined"

- name: Add service to parameters
  ansible.builtin.set_fact:
    convert_params: "{{ convert_params }} --service '{{ doc_service }}'"
  when: "doc_service is defined"

- name: Add repo_name to parameters
  ansible.builtin.set_fact:
    convert_params: "{{ convert_params }} --repo-name '{{ doc_repo_name }}'"
  when: "doc_repo_name is defined"

- name: Add pdf_name to parameters
  ansible.builtin.set_fact:
    convert_params: "{{ convert_params }} --pdf-name {{ doc_pdf_name }}"
  when: "doc_pdf_name is defined"

- name: Add templates-location to parameters
  ansible.builtin.set_fact:
    convert_params: "{{ convert_params }} --templates-location {{ zuul_work_dir }}/templates"


- name: Convert {{ doc_label | default('') }} HTML to RST
  args:
    executable: "/bin/bash"
  ansible.builtin.shell: "source {{ zuul_work_virtualenv }}/bin/activate; otc-convert-doc {{ convert_params }} {{ source }}"
