@@ -9,12 +9,11 @@ SPHINXBUILD ?= sphinx-build
9
9
SOURCEDIR = source
10
10
BUILDDIR = build
11
11
ROOT_DIR: =$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST ) ) ) )
12
+ OS_DISTRO := $(shell uname)
13
+ INDEX_HTML = build/html/index.html
12
14
line_header="=================================================================== ="
13
15
14
-
15
- view-html :
16
- @echo " Display generated HTML in default browser."
17
- @open build/html/index.html
16
+ .PHONY : help Makefile
18
17
19
18
# Put it first so that "make" without argument is like "make help".
20
19
help :
48
47
@echo $(line_header)
49
48
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
50
49
51
- .PHONY : help Makefile
50
+ view-html :
51
+ ifeq ($(shell test -e $(INDEX_HTML ) && echo true) ,true)
52
+ @echo "Display generated HTML '$(INDEX_HTML)' in default browser."
53
+ ifeq ($(OS_DISTRO ) , Darwin)
54
+ @open build/html/index.html
55
+ else ifeq ($(OS_DISTRO), Linux)
56
+ @xdg-open build/html/index.html &> /dev/null &
57
+ else
58
+ @echo "Unable to launch browser for $(INDEX_HTML), open file with your browser."
59
+ endif
60
+ else
61
+ @echo "Unable to find generated HTML '$(INDEX_HTML)'."
62
+ endif
52
63
53
64
clean :
54
65
@echo $(line_header )
@@ -98,16 +109,16 @@ role-doc:
98
109
fi
99
110
100
111
@for role_name in `ls ../roles/`; do \
101
- echo "Detected role name $$role_name"; \
102
- if test -e ../roles/$$role_name/docs/doc_$$role_name; then \
103
- echo "Copying metadata ../roles/$$role_name/docs/doc_$$role_name to ../roles/$$role_name/docs/doc_$$role_name.py"; \
104
- cp ../roles/$$role_name/docs/doc_$$role_name ../roles/$$role_name/docs/doc_$$role_name.py; \
105
- echo "Sanitizing metadata ../roles/$$role_name/docs/doc_$$role_name.py"; \
106
- sed -i "" "s/role:/module:/g " ../roles/$$role_name/docs/doc_$$role_name.py; \
107
- echo "Generating RST doc for role ../roles/$$role_name"; \
108
- ansible-doc-extractor --template templates/role.rst.j2 source/roles ../roles/$$role_name/docs/doc_$$role_name.py; \
109
- echo "Deleting generated metadata ../roles/$$role_name/docs/doc_$$role_name.py"; \
110
- rm -rf ../roles/$$role_name/docs/doc_$$role_name.py; \
112
+ echo "Detected role name $$role_name"; \
113
+ if test -e ../roles/$$role_name/docs/doc_$$role_name; then \
114
+ echo "Copying metadata ../roles/$$role_name/docs/doc_$$role_name to ../roles/$$role_name/docs/doc_$$role_name.py"; \
115
+ cp ../roles/$$role_name/docs/doc_$$role_name ../roles/$$role_name/docs/doc_$$role_name.py; \
116
+ echo "Sanitizing metadata ../roles/$$role_name/docs/doc_$$role_name.py"; \
117
+ sed -i -e "s/^ role:/module:/" ../roles/$$role_name/docs/doc_$$role_name.py; \
118
+ echo "Generating RST doc for role ../roles/$$role_name"; \
119
+ ansible-doc-extractor --template templates/role.rst.j2 source/roles ../roles/$$role_name/docs/doc_$$role_name.py; \
120
+ echo "Deleting generated metadata ../roles/$$role_name/docs/doc_$$role_name.py"; \
121
+ rm -rf ../roles/$$role_name/docs/doc_$$role_name.py; \
111
122
fi; \
112
123
done
113
124
@@ -130,31 +141,31 @@ module-doc:
130
141
mkdir -p source/modules; \
131
142
fi
132
143
133
- @if ! test -d ../plugins/modules/rexx_module_doc; then \
134
- echo "Make ../plugins/modules/rexx_module_doc directory to extract REXX doc into temporary file."; \
135
- mkdir -p ../plugins/modules/rexx_module_doc; \
136
- else \
137
- echo "Delete ../plugins/modules/rexx_module_doc directory used to extract REXX doc into temporary file."; \
138
- rm -rf ../plugins/modules/rexx_module_doc; \
139
- echo "Make ../plugins/modules/rexx_module_doc directory to extract REXX doc into temporary file."; \
140
- mkdir -p ../plugins/modules/rexx_module_doc; \
141
- fi
142
-
143
- @for rexx_module in `ls ../plugins/modules/*rexx`; do\
144
- REXX_FILE=`basename $$rexx_module .rexx`; \
145
- echo "Extracting documentation for module $$REXX_FILE into ../plugins/modules/rexx_module_doc/$$REXX_FILE.py"; \
146
- touch ../plugins/modules/rexx_module_doc/$$REXX_FILE.py; \
147
- sed -n "/DOCUMENTATION = '''/,/'''/p" ../plugins/modules/$$REXX_FILE.rexx >> ../plugins/modules/rexx_module_doc/$$REXX_FILE.py; \
148
- sed -n "/EXAMPLES = '''/,/'''/p" ../plugins/modules/$$REXX_FILE.rexx >> ../plugins/modules/rexx_module_doc/$$REXX_FILE.py; \
149
- sed -n "/RETURN = '''/,/'''/p" ../plugins/modules/$$REXX_FILE.rexx >> ../plugins/modules/rexx_module_doc/$$REXX_FILE.py; \
150
- echo "Generating ReStructuredText for module $$REXX_FILE inot source/modules/$$REXX_FILE.rst"; \
151
- ansible-doc-extractor --template templates/module.rst.j2 source/modules ../plugins/modules/rexx_module_doc/$$REXX_FILE.py; \
152
- done
153
-
154
- @if test -d ../plugins/modules/rexx_module_doc; then \
155
- echo "Delete ../plugins/modules/rexx_module_doc directory used to extract REXX doc into temporary file."; \
156
- rm -rf ../plugins/modules/rexx_module_doc; \
157
- fi
144
+ # @if ! test -d ../plugins/modules/rexx_module_doc; then \
145
+ # echo "Make ../plugins/modules/rexx_module_doc directory to extract REXX doc into temporary file."; \
146
+ # mkdir -p ../plugins/modules/rexx_module_doc; \
147
+ # else \
148
+ # echo "Delete ../plugins/modules/rexx_module_doc directory used to extract REXX doc into temporary file."; \
149
+ # rm -rf ../plugins/modules/rexx_module_doc; \
150
+ # echo "Make ../plugins/modules/rexx_module_doc directory to extract REXX doc into temporary file."; \
151
+ # mkdir -p ../plugins/modules/rexx_module_doc; \
152
+ # fi
153
+
154
+ # @for rexx_module in `ls ../plugins/modules/*rexx`; do\
155
+ # REXX_FILE=`basename $$rexx_module .rexx`; \
156
+ # echo "Extracting documentation for module $$REXX_FILE into ../plugins/modules/rexx_module_doc/$$REXX_FILE.py"; \
157
+ # touch ../plugins/modules/rexx_module_doc/$$REXX_FILE.py; \
158
+ # sed -n "/DOCUMENTATION = '''/,/'''/p" ../plugins/modules/$$REXX_FILE.rexx >> ../plugins/modules/rexx_module_doc/$$REXX_FILE.py; \
159
+ # sed -n "/EXAMPLES = '''/,/'''/p" ../plugins/modules/$$REXX_FILE.rexx >> ../plugins/modules/rexx_module_doc/$$REXX_FILE.py; \
160
+ # sed -n "/RETURN = '''/,/'''/p" ../plugins/modules/$$REXX_FILE.rexx >> ../plugins/modules/rexx_module_doc/$$REXX_FILE.py; \
161
+ # echo "Generating ReStructuredText for module $$REXX_FILE inot source/modules/$$REXX_FILE.rst"; \
162
+ # ansible-doc-extractor --template templates/module.rst.j2 source/modules ../plugins/modules/rexx_module_doc/$$REXX_FILE.py; \
163
+ # done
164
+
165
+ # @if test -d ../plugins/modules/rexx_module_doc; then \
166
+ # echo "Delete ../plugins/modules/rexx_module_doc directory used to extract REXX doc into temporary file."; \
167
+ # rm -rf ../plugins/modules/rexx_module_doc; \
168
+ # fi
158
169
159
170
@if test -e ../plugins/modules/__init__.py; then \
160
171
echo "Rename file '../plugins/modules/__init__.py' to ../plugins/modules/__init__.py.skip to avoid reading empty python file.'"; \
0 commit comments