| skipped 27 lines |
28 | 28 | | CURRENT_DIR = Path(__file__).parent |
29 | 29 | | LIEF_ROOT_DIR = (CURRENT_DIR / "../..").resolve().absolute() |
30 | 30 | | |
31 | | - | GENERATE_DOXYGEN = False |
32 | | - | DOXYGEN_XML_PATH = None |
33 | | - | USE_RTD_THEME = False |
34 | | - | |
35 | | - | try: |
36 | | - | import sphinx_lief |
37 | | - | except Exception: |
38 | | - | import sphinx_rtd_theme |
39 | | - | USE_RTD_THEME = True |
40 | | - | |
41 | | - | |
42 | | - | try: |
43 | | - | import breathe |
44 | | - | DOXYGEN_XML_PATH = os.getenv("LIEF_DOXYGEN_XML", None) |
45 | | - | if DOXYGEN_XML_PATH is not None and pathlib.Path(DOXYGEN_XML_PATH).exists(): |
46 | | - | DOXYGEN_XML_PATH = pathlib.Path(DOXYGEN_XML_PATH).resolve().absolute() |
47 | | - | GENERATE_DOXYGEN = True |
48 | | - | except Exception: |
49 | | - | GENERATE_DOXYGEN = False |
50 | | - | |
51 | | - | |
52 | | - | FORCE_RTD_THEME = os.environ.get("FORCE_RTD_THEME", False) |
53 | | - | FORCE_RTD_THEME = FORCE_RTD_THEME in ("1", "true", "yes") |
54 | | - | |
55 | | - | if FORCE_RTD_THEME: |
56 | | - | import sphinx_rtd_theme |
| 31 | + | import sphinx_lief |
| 32 | + | import breathe |
57 | 33 | | |
58 | | - | USE_RTD_THEME = USE_RTD_THEME or FORCE_RTD_THEME |
| 34 | + | DOXYGEN_XML_PATH = os.getenv("LIEF_DOXYGEN_XML", None) |
| 35 | + | DOXYGEN_XML_PATH = pathlib.Path(DOXYGEN_XML_PATH).resolve().absolute() |
59 | 36 | | |
60 | 37 | | extensions = [ |
61 | 38 | | 'sphinx.ext.mathjax', |
62 | 39 | | 'sphinx.ext.autodoc', |
63 | 40 | | 'sphinx.ext.inheritance_diagram', |
| 41 | + | 'breathe', 'sphinx_lief' |
64 | 42 | | ] |
65 | 43 | | |
| 44 | + | def get_breathe_projects_source(): |
| 45 | + | LIEF_C_INCLUDE = LIEF_ROOT_DIR / "api/c/include" |
| 46 | + | files = [] |
| 47 | + | for file in LIEF_C_INCLUDE.rglob("*.h"): |
| 48 | + | files.append(file.relative_to(LIEF_C_INCLUDE)) |
| 49 | + | return (LIEF_C_INCLUDE.as_posix(), files) |
66 | 50 | | |
67 | | - | if GENERATE_DOXYGEN: |
68 | | - | def get_breathe_projects_source(): |
69 | | - | LIEF_C_INCLUDE = LIEF_ROOT_DIR / "api/c/include" |
70 | | - | files = [] |
71 | | - | for file in LIEF_C_INCLUDE.rglob("*.h"): |
72 | | - | files.append(file.relative_to(LIEF_C_INCLUDE)) |
73 | | - | return (LIEF_C_INCLUDE.as_posix(), files) |
74 | | - | PREDEFINED = ( |
75 | | - | "LIEF_API=", |
76 | | - | "LIEF_LOCAL=", |
77 | | - | "__cplusplus", |
78 | | - | ) |
79 | | - | EXPAND_AS_DEFINED = ( |
80 | | - | "_LIEF_EI", |
81 | | - | "_LIEF_EN", |
82 | | - | "_LIEF_EN_2", |
83 | | - | ) |
84 | | - | extensions += ["breathe"] |
85 | | - | breathe_projects = { |
86 | | - | "lief": DOXYGEN_XML_PATH, |
87 | | - | } |
| 51 | + | PREDEFINED = ( |
| 52 | + | "LIEF_API=", |
| 53 | + | "LIEF_LOCAL=", |
| 54 | + | "__cplusplus", |
| 55 | + | ) |
88 | 56 | | |
89 | | - | breathe_domain_by_extension = { |
90 | | - | "h" : "c", |
91 | | - | "hpp" : "cpp", |
92 | | - | } |
| 57 | + | EXPAND_AS_DEFINED = ( |
| 58 | + | "_LIEF_EI", |
| 59 | + | "_LIEF_EN", |
| 60 | + | "_LIEF_EN_2", |
| 61 | + | ) |
| 62 | + | breathe_projects = { |
| 63 | + | "lief": DOXYGEN_XML_PATH, |
| 64 | + | } |
93 | 65 | | |
94 | | - | breathe_doxygen_config_options = { |
95 | | - | "WARN_IF_UNDOCUMENTED": "NO", |
96 | | - | "MACRO_EXPANSION": "YES", |
97 | | - | 'PREDEFINED': " ".join(PREDEFINED), |
98 | | - | 'EXPAND_AS_DEFINED': " ".join(EXPAND_AS_DEFINED) |
99 | | - | } |
| 66 | + | breathe_domain_by_extension = { |
| 67 | + | "h" : "c", |
| 68 | + | "hpp" : "cpp", |
| 69 | + | } |
100 | 70 | | |
101 | | - | # This is used for generating the C API |
102 | | - | breathe_projects_source = { |
103 | | - | "lief" : get_breathe_projects_source() |
104 | | - | } |
| 71 | + | breathe_doxygen_config_options = { |
| 72 | + | "WARN_IF_UNDOCUMENTED": "NO", |
| 73 | + | "MACRO_EXPANSION": "YES", |
| 74 | + | 'PREDEFINED': " ".join(PREDEFINED), |
| 75 | + | 'EXPAND_AS_DEFINED': " ".join(EXPAND_AS_DEFINED) |
| 76 | + | } |
105 | 77 | | |
106 | | - | breathe_default_project = "lief" |
| 78 | + | # This is used for generating the C API |
| 79 | + | breathe_projects_source = { |
| 80 | + | "lief" : get_breathe_projects_source() |
| 81 | + | } |
| 82 | + | |
| 83 | + | breathe_default_project = "lief" |
107 | 84 | | |
108 | 85 | | logger = logging.getLogger("lief-doc") |
109 | 86 | | # Add any paths that contain templates here, relative to this directory. |
| skipped 24 lines |
134 | 111 | | 'members': True, |
135 | 112 | | } |
136 | 113 | | |
137 | | - | if GENERATE_DOXYGEN: |
138 | | - | breathe_default_members = ('members', 'protected-members', 'undoc-members') |
139 | | - | breathe_show_enumvalue_initializer = True |
| 114 | + | breathe_default_members = ('members', 'protected-members', 'undoc-members') |
| 115 | + | breathe_show_enumvalue_initializer = True |
140 | 116 | | |
141 | 117 | | #exclude_patterns = [ |
142 | 118 | | # "tutorials/*.rst", |
| skipped 162 lines |
305 | 281 | | lines[:] = [] |
306 | 282 | | return |
307 | 283 | | |
308 | | - | |
309 | 284 | | class LIEFInheritanceDiagram(InheritanceDiagram): |
310 | 285 | | option_spec: OptionSpec = { |
311 | 286 | | **InheritanceDiagram.option_spec, |
| skipped 50 lines |
362 | 337 | | ] |
363 | 338 | | |
364 | 339 | | |
365 | | - | if not USE_RTD_THEME: |
366 | | - | pygments_style = "xcode" |
367 | | - | endpoint = "stable" if lief.__is_tagged__ else "latest" |
368 | | - | extensions.append("sphinx_lief") |
369 | | - | html_theme_path = sphinx_lief.html_theme_path() |
370 | | - | html_context = sphinx_lief.get_html_context() |
371 | | - | html_theme = "sphinx_lief" |
372 | | - | html_base_url = "https://lief-project.github.io/" |
373 | | - | base_url = f"{html_base_url}/doc/{endpoint}" |
374 | | - | html_theme_options = { |
375 | | - | "commit": commit, |
376 | | - | "base_url": f"{base_url}/", |
377 | | - | "sponsor_link": "https://github.com/sponsors/lief-project/", |
378 | | - | "repo_url": "https://github.com/lief-project/LIEF/", |
379 | | - | "repo_name": "LIEF", |
380 | | - | "html_minify": True, |
381 | | - | "html_prettify": False, |
382 | | - | "css_minify": True, |
383 | | - | "logo_icon": "logo_blue.png", |
384 | | - | "globaltoc_depth": 2, |
385 | | - | "color_primary": "blue", |
386 | | - | "color_accent": "cyan", |
387 | | - | "touch_icon": "favicon.ico", |
388 | | - | "nav_links": [ |
389 | | - | { |
390 | | - | "href": html_base_url, |
391 | | - | "internal": False, |
392 | | - | "title": "Home", |
393 | | - | "icon": "fa-solid fa-house" |
394 | | - | }, |
395 | | - | { |
396 | | - | "href": f"{html_base_url}/blog", |
397 | | - | "internal": False, |
398 | | - | "title": "Blog", |
399 | | - | "icon": "fa-solid fa-rss" |
400 | | - | }, |
401 | | - | { |
402 | | - | "href": f"{html_base_url}/download", |
403 | | - | "internal": False, |
404 | | - | "title": "Download", |
405 | | - | "icon": "fa-solid fa-download", |
406 | | - | }, |
407 | | - | { |
408 | | - | "href": "index", |
409 | | - | "internal": True, |
410 | | - | "title": "Documentation", |
411 | | - | "icon": "fa-solid fa-book", |
412 | | - | "subnav": [ |
413 | | - | { |
414 | | - | "title": "Doxygen", |
415 | | - | "href": f"{base_url}/doxygen", |
416 | | - | }, |
417 | | - | ] |
418 | | - | }, |
419 | | - | { |
420 | | - | "href": f"{html_base_url}/about", |
421 | | - | "internal": False, |
422 | | - | "title": "About", |
423 | | - | "icon": "fa-solid fa-bars-staggered" |
424 | | - | }, |
425 | | - | ], |
426 | | - | "table_classes": ["plain"], |
427 | | - | } |
428 | | - | else: |
429 | | - | html_theme = "sphinx_rtd_theme" |
430 | | - | html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] |
| 340 | + | pygments_style = "xcode" |
| 341 | + | endpoint = "stable" if lief.__is_tagged__ else "latest" |
| 342 | + | |
| 343 | + | html_theme_path = sphinx_lief.html_theme_path() |
| 344 | + | html_context = sphinx_lief.get_html_context() |
| 345 | + | html_theme = "sphinx_lief" |
| 346 | + | html_base_url = "https://lief-project.github.io/" |
| 347 | + | base_url = f"{html_base_url}/doc/{endpoint}" |
| 348 | + | html_theme_options = { |
| 349 | + | "commit": commit, |
| 350 | + | "base_url": f"{base_url}/", |
| 351 | + | "sponsor_link": "https://github.com/sponsors/lief-project/", |
| 352 | + | "repo_url": "https://github.com/lief-project/LIEF/", |
| 353 | + | "repo_name": "LIEF", |
| 354 | + | "html_minify": True, |
| 355 | + | "html_prettify": False, |
| 356 | + | "css_minify": True, |
| 357 | + | "logo_icon": "logo_blue.png", |
| 358 | + | "globaltoc_depth": 2, |
| 359 | + | "color_primary": "blue", |
| 360 | + | "color_accent": "cyan", |
| 361 | + | "touch_icon": "favicon.ico", |
| 362 | + | "nav_links": [ |
| 363 | + | { |
| 364 | + | "href": html_base_url, |
| 365 | + | "internal": False, |
| 366 | + | "title": "Home", |
| 367 | + | "icon": "fa-solid fa-house" |
| 368 | + | }, |
| 369 | + | { |
| 370 | + | "href": f"{html_base_url}/blog", |
| 371 | + | "internal": False, |
| 372 | + | "title": "Blog", |
| 373 | + | "icon": "fa-solid fa-rss" |
| 374 | + | }, |
| 375 | + | { |
| 376 | + | "href": f"{html_base_url}/download", |
| 377 | + | "internal": False, |
| 378 | + | "title": "Download", |
| 379 | + | "icon": "fa-solid fa-download", |
| 380 | + | }, |
| 381 | + | { |
| 382 | + | "href": "index", |
| 383 | + | "internal": True, |
| 384 | + | "title": "Documentation", |
| 385 | + | "icon": "fa-solid fa-book", |
| 386 | + | "subnav": [ |
| 387 | + | { |
| 388 | + | "title": "Doxygen", |
| 389 | + | "href": f"{base_url}/doxygen", |
| 390 | + | }, |
| 391 | + | ] |
| 392 | + | }, |
| 393 | + | { |
| 394 | + | "href": f"{html_base_url}/about", |
| 395 | + | "internal": False, |
| 396 | + | "title": "About", |
| 397 | + | "icon": "fa-solid fa-bars-staggered" |
| 398 | + | }, |
| 399 | + | ], |
| 400 | + | "table_classes": ["plain"], |
| 401 | + | } |
431 | 402 | | |
432 | 403 | | html_last_updated_fmt = '%d/%m/%Y, %H:%M:%S' |
433 | 404 | | html_logo = '_static/logo_blue.png' |
| skipped 5 lines |