Add new elements at Sphinx initialization time. Parameters ---------- app : object The application object representing the Sphinx process.
(app)
| 261 | |
| 262 | |
| 263 | def setup(app): |
| 264 | """Add new elements at Sphinx initialization time. |
| 265 | |
| 266 | Parameters |
| 267 | ---------- |
| 268 | app : object |
| 269 | The application object representing the Sphinx process. |
| 270 | """ |
| 271 | first_run = not os.path.exists(os.path.join(CURR_PATH, '_FIRST_RUN.flag')) |
| 272 | if first_run and RTD: |
| 273 | open(os.path.join(CURR_PATH, '_FIRST_RUN.flag'), 'w').close() |
| 274 | if C_API: |
| 275 | app.connect("builder-inited", generate_doxygen_xml) |
| 276 | else: |
| 277 | app.add_directive('doxygenfile', IgnoredDirective) |
| 278 | if RTD: # build R docs only on Read the Docs site |
| 279 | if first_run: |
| 280 | app.connect("builder-inited", generate_r_docs) |
| 281 | app.connect("build-finished", |
| 282 | lambda app, exception: copy_tree(os.path.join(CURR_PATH, os.path.pardir, "lightgbm_r", "docs"), |
| 283 | os.path.join(app.outdir, "R"), verbose=0)) |
| 284 | add_js_file = getattr(app, 'add_js_file', False) or app.add_javascript |
| 285 | add_js_file("js/script.js") |