command-line-formatter: Stop uselessly looping over options
[platform/upstream/gstreamer.git] / docs / meson.build
1 build_hotdoc = false
2
3 if meson.is_cross_build()
4     if get_option('doc').enabled()
5         error('Documentation enabled but building the doc while cross building is not supported yet.')
6     endif
7
8     message('Documentation not built as building it while cross building is not supported yet.')
9     subdir_done()
10 endif
11
12 required_hotdoc_extensions = ['gi-extension', 'gst-extension']
13 if gst_dep.type_name() == 'internal'
14     gst_proj = subproject('gstreamer')
15     plugins_cache_generator = gst_proj.get_variable('plugins_cache_generator')
16 else
17     plugins_cache_generator = find_program(join_paths(gst_dep.get_pkgconfig_variable('libexecdir'), 'gstreamer-' + apiversion, 'gst-plugins-doc-cache-generator'), required: false)
18 endif
19
20 plugins_cache = join_paths(meson.current_source_dir(), 'gst_plugins_cache.json')
21
22 if plugins_cache_generator.found()
23     plugins_doc_dep = custom_target('editing-services-doc-cache',
24         command: [plugins_cache_generator, plugins_cache, '@OUTPUT@', '@INPUT@'],
25         input: plugins,
26         output: 'gst_plugins_cache.json',
27         build_always_stale: true,
28     )
29 else
30     warning('GStreamer plugin inspector for documentation not found, can\'t update the cache')
31 endif
32
33 hotdoc_p = find_program('hotdoc', required: get_option('doc'))
34 if not hotdoc_p.found()
35     message('Hotdoc not found, not building the documentation')
36     subdir_done()
37 endif
38
39 hotdoc_req = '>= 0.11.0'
40 hotdoc_version = run_command(hotdoc_p, '--version').stdout()
41 if not hotdoc_version.version_compare(hotdoc_req)
42     if get_option('doc').enabled()
43         error('Hotdoc version @0@ not found, got @1@'.format(hotdoc_req, hotdoc_version))
44     else
45         message('Hotdoc version @0@ not found, got @1@, not building documentation'.format(hotdoc_req, hotdoc_version))
46         subdir_done()
47     endif
48 endif
49
50 hotdoc = import('hotdoc')
51 foreach extension: required_hotdoc_extensions
52     if not hotdoc.has_extensions(extension)
53         if get_option('doc').enabled()
54             error('Documentation enabled but gi-extension missing')
55         endif
56
57         message('@0@ extensions not found, not building documentation requiring it'.format(extension))
58     endif
59 endforeach
60
61 if not build_gir
62     if get_option('doc').enabled()
63         error('Documentation enabled but introspection not built.')
64     endif
65
66     message('Introspection not built, can\'t build the documentation')
67     subdir_done()
68 endif
69
70 build_hotdoc = true
71 ges_excludes = []
72 foreach f: ['gesmarshal.*',
73             'ges-internal.*',
74             'ges-auto-transition.*',
75             'ges-structured-interface.*',
76             'ges-structure-parser.*',
77             'ges-version.h',
78             'ges-smart-*',
79             'ges-command-line-formatter.*',
80             'ges-base-xml-formatter.h',
81             'gstframepositioner.*',
82             'lex.priv_ges_parse_yy.c',
83             'ges-parse-lex.[c]']
84     ges_excludes += [join_paths(meson.current_source_dir(), '..', '..', 'ges', f)]
85 endforeach
86
87 hotdoc = import('hotdoc')
88 libs_doc = [hotdoc.generate_doc('gst-editing-services',
89     project_version: apiversion,
90     extra_assets: [join_paths(meson.current_source_dir(), 'images')],
91     gi_c_sources: ges_sources + ges_headers,
92     gi_c_source_roots: [join_paths(meson.current_source_dir(), '../ges/')],
93     gi_sources: [ges_gir[0].full_path()],
94     gi_c_source_filters: ges_excludes,
95     sitemap: 'sitemap.txt',
96     index: 'index.md',
97     gi_index: 'index.md',
98     gi_smart_index: true,
99     gi_order_generated_subpages: true,
100     dependencies: [ges_dep],
101     disable_incremental_build: true,
102 )]
103
104 plugins_doc = []
105 list_plugin_res = run_command(python3, '-c',
106 '''
107 import sys
108 import json
109
110 with open("@0@") as f:
111     print(':'.join(json.load(f).keys()), end='')
112 '''.format(plugins_cache))
113
114 assert(list_plugin_res.returncode() == 0,
115   'Could not list plugins from @0@\n@1@\n@1@'.format(plugins_cache, list_plugin_res.stdout(), list_plugin_res.stderr()))
116
117
118 foreach plugin_name: list_plugin_res.stdout().split(':')
119     plugins_doc += [hotdoc.generate_doc(plugin_name,
120         project_version: apiversion,
121         sitemap: 'plugins/sitemap.txt',
122         index: 'plugins/index.md',
123         gst_index: 'plugins/index.md',
124         gst_smart_index: true,
125         gst_c_sources: ['../plugins/*/*.[ch]',],
126         dependencies: [gst_dep, plugins],
127         gst_order_generated_subpages: true,
128         gst_cache_file: plugins_cache,
129         gst_plugin_name: plugin_name,
130     )]
131 endforeach