summaryrefslogtreecommitdiff
path: root/roles/sphinx/tasks/main.yaml
blob: a08d428bb7805a643c015b668f8840a008aa3ebc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
- name: By default, we use standard doc dir
  set_fact:
    use_doc_dir: true

- name: Check if sphinx_source_dir was changed
  set_fact:
    use_doc_dir: false
  when: sphinx_source_dir != "doc/source"

- name: Attempt to get warning-is-error from config file
  when:
    - use_doc_dir
    - sphinx_warning_is_error is not defined
  sphinx_check_warning_is_error:
    project_dir: "{{ zuul_work_dir }}"
  register: check_result

- name: Set sphinx_warning_is_error
  when:
    - use_doc_dir
    - sphinx_warning_is_error is not defined
  set_fact:
    sphinx_warning_is_error: "{{ check_result.warning_is_error }}"
    sphinx_pbr_autodoc: "{{ check_result.autodoc_index_modules }}"

- name: Set sphinx_warning_is_error
  when:
    - not use_doc_dir
    - sphinx_warning_is_error is not defined
  set_fact:
    # Non-default dirs always enable warnings
    sphinx_warning_is_error: true
    sphinx_pbr_autodoc: false

- name: Run sphinx
  shell:
    executable: /bin/bash
    cmd: |
      # Source the activate file so that sphinx subcommands have the correct
      # paths set.
      source {{ zuul_work_virtualenv }}/bin/activate
      sphinx-build -b {{ item }} \
        {% if sphinx_warning_is_error %} -W {% endif %} \
        {{ sphinx_source_dir }} {{ sphinx_build_dir }}/{{ item }}
    chdir: "{{ zuul_work_dir }}"
  with_items: "{{ sphinx_builders }}"
  when:
    - not use_doc_dir or not sphinx_pbr_autodoc

# TODO(mordred) Remove this when we get projects off of the pbr autoindex
- name: Run sphinx using legacy pbr runner
  shell:
    executable: /bin/bash
    cmd: |
      # Source the activate file so that sphinx subcommands have the correct
      # paths set.
      source {{ zuul_work_virtualenv }}/bin/activate
      python setup.py build_sphinx
    chdir: "{{ zuul_work_dir }}"
  when:
    - use_doc_dir
    - sphinx_pbr_autodoc

- name: Check for whereto
  stat:
    path: "{{ zuul_work_virtualenv }}/bin/whereto"
    get_checksum: false
    get_mime: false
    get_md5: false
  register: whereto

- name: Check for htaccess
  stat:
    path: "{{ zuul_work_dir }}/{{ sphinx_source_dir }}/_extra/.htaccess"
    get_checksum: false
    get_mime: false
    get_md5: false
  register: htaccess

- name: Run whereto
  command:
    cmd: "{{ whereto.stat.path }} {{ sphinx_source_dir }}/_extra/.htaccess doc/test/redirect-tests.txt"
    chdir: "{{ zuul_work_dir }}"
  when:
    - whereto.stat.exists
    - htaccess.stat.exists
    - use_doc_dir