diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 563d774..6279b0c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,9 @@ jobs: node-version: [16.x, 18.x] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + with: + submodules: true - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 @@ -44,7 +46,9 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 + with: + submodules: true - name: Install the dependencies run: | diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e99ce54..bb076cc 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Clone - uses: actions/checkout@v2 + uses: actions/checkout@v4 + with: + submodules: true - name: Install the dependencies run: | diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..5243197 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,8 @@ +[submodule "girs"] + path = girs + url = https://github.com/nemequ/vala-girs.git + shallow = true +[submodule "extra-vapis"] + path = extra-vapis + url = https://gitlab.gnome.org/GNOME/vala-extra-vapis.git + shallow = true diff --git a/Makefile b/Makefile index 31ade8b..a23a44e 100644 --- a/Makefile +++ b/Makefile @@ -64,8 +64,7 @@ configgen: src/configgen.vala update-girs: - [ -d girs ] && git -C girs pull || git clone https://github.com/nemequ/vala-girs.git girs --depth 1 - [ -d extra-vapis ] && git -C extra-vapis pull || git clone https://gitlab.gnome.org/GNOME/vala-extra-vapis.git extra-vapis --depth 1 + git submodule update --remote --init # diff --git a/extra-vapis b/extra-vapis new file mode 160000 index 0000000..a53319e --- /dev/null +++ b/extra-vapis @@ -0,0 +1 @@ +Subproject commit a53319e7cd8564712ddd550867b1a1af9317b75b diff --git a/girs b/girs new file mode 160000 index 0000000..167d367 --- /dev/null +++ b/girs @@ -0,0 +1 @@ +Subproject commit 167d367f42d6d3e218480b87c91fc4f3dcbc4107 diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..a609808 --- /dev/null +++ b/meson.build @@ -0,0 +1,156 @@ +project('valadoc-org', 'vala', 'c') + +vala_api_version = run_command (meson.get_compiler('vala'), '--api-version', check: true).stdout().strip() +data_dir = meson.current_source_dir() + +config_vapi = meson.get_compiler('vala').find_library('config', dirs: meson.current_source_dir() / 'src') + +config_dep = declare_dependency( + dependencies: config_vapi +) + +gee_dep = dependency('gee-0.8') +valadoc_dep = dependency('valadoc-@0@'.format(vala_api_version)) +libvala_dep = dependency('libvala-@0@'.format(vala_api_version)) +gio_dep = dependency('gio-2.0') +glib_dep = dependency('glib-2.0') +gobject_dep = dependency('gobject-2.0') + +example_gen = executable( + 'valadoc-example-gen', + 'src/valadoc-example-parser.vala', + 'src/valadoc-example-gen.vala', + dependencies: [ + glib_dep, + gobject_dep, + ] +) + +example_tester = executable( + 'valadoc-example-tester', + 'src/valadoc-example-parser.vala', + 'src/valadoc-example-tester.vala', + dependencies: [ + glib_dep, + gobject_dep, + ] +) + +doclet = shared_module( + 'doclet', + 'src/doclet.vala', + 'src/linkhelper.vala', + dependencies: [ + glib_dep, + gobject_dep, + gee_dep, + valadoc_dep, + ] +) + +generator = executable( + 'generator', + 'src/doclet.vala', + 'src/linkhelper.vala', + 'src/generator.vala', + dependencies: [ + glib_dep, + gobject_dep, + gio_dep, + gee_dep, + valadoc_dep, + ] +) + +configgen = executable( + 'configgen', + 'src/configgen.vala', + dependencies: [ + glib_dep, + gobject_dep, + config_dep, + ], + c_args : [ + '-Ddatadir="@0@"'.format(data_dir), + ], +) + +# +# Example checks: +# + +examples_files = files( + 'examples/cairo/cairo.valadoc.examples', + 'examples/gee-0.8/gee-0.8.valadoc.examples', + 'examples/gio-2.0/gio-2.0.valadoc.examples', + 'examples/glib-2.0/glib-2.0.valadoc.examples', + 'examples/gmodule-2.0/gmodule-2.0.valadoc.examples', + 'examples/gmodule-2.0/gmodule-2.0.valadoc.examples', + 'examples/gobject-2.0/gobject-2.0.valadoc.examples', + 'examples/gstreamer-1.0/gstreamer-1.0.valadoc.examples', + 'examples/gstreamer-video-1.0/gstreamer-video-1.0.valadoc.examples', + 'examples/gtk+-3.0/gtk+-3.0.valadoc.examples', + 'examples/json-glib-1.0/json-glib-1.0.valadoc.examples', + 'examples/libnotify/libnotify.valadoc.examples', + 'examples/libsoup-2.4/libsoup-2.4.valadoc.examples', + 'examples/libxml-2.0/libxml-2.0.valadoc.examples', + 'examples/rest-0.7/rest-0.7.valadoc.examples', + 'examples/sqlite3/sqlite3.valadoc.examples' +) + +run_target('check-examples', + command: [ + example_tester, + '--keep-running', '--force', + examples_files, + ] +) + +# +# Build local assets +# +run_target('build-data', + command: ['npx', 'gulp',] +) + +# +# Documentation generation: +# +packages = get_option('packages') +if packages.length() == 0 + packages = '--all' +endif + +run_target('build-docs', + command: [ + generator, + '--vapidir', libvala_dep.get_variable('vapidir'), + '--vapidir', meson.current_source_dir() / 'extra-vapis', + '--vapidir', meson.current_source_dir() / 'girs/vala/vapi', + '--prefix', get_option('doc_prefix'), + '--target-glib', '2.98', + '--download-images', + '--no-check-certificate', + '--directory', meson.current_build_dir() / 'valadoc.org', + get_option('generator_options'), + packages + ] +) + +run_target('build-docs-mini', + command: [ + generator, + '--vapidir', libvala_dep.get_variable('vapidir'), + '--vapidir', meson.current_source_dir() / 'extra-vapis', + '--vapidir', meson.current_source_dir() / 'girs/vala/vapi', + '--prefix', get_option('doc_prefix'), + '--target-glib', '2.98', + '--download-images', + '--no-check-certificate', + '--directory', meson.current_build_dir() / 'valadoc.org', + get_option('generator_options'), + 'glib-2.0', + 'gio-2.0', + 'gobject-2.0', + ] +) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..a1f2cd3 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,3 @@ +option('generator_options', type : 'array', value : ['--disable-devhelp', '--skip-existing'], description : 'The options to give to the generator') +option('packages', type : 'array', value : [], description : 'The packages to generate, none means all') +option('doc_prefix', type : 'string', value : 'stable', description : 'The documentation prefix') diff --git a/src/generator.vala b/src/generator.vala index 9ad1c19..2c0772e 100644 --- a/src/generator.vala +++ b/src/generator.vala @@ -828,8 +828,9 @@ public class Valadoc.IndexGenerator : Valadoc.ValadocOrgDoclet { StringBuilder builder = new StringBuilder (); - builder.append_printf ("valadoc --target-glib %s --importdir girs --doclet \"%s\" -o \"tmp/%s\" \"%s\" --vapidir \"%s\" --girdir \"%s\" %s --use-svg-images", - target_glib, docletpath, pkg.name, pkg.get_vapi_path (vapidirs), Path.get_dirname (pkg.get_vapi_path (vapidirs)), girdir, pkg.flags); + var tmp_dir = GLib.DirUtils.make_tmp ("valadoc-gen-XXXXXX"); + builder.append_printf ("valadoc --target-glib %s --importdir girs --doclet \"%s\" -o \"%s/%s\" \"%s\" --vapidir \"%s\" --girdir \"%s\" %s --use-svg-images", + target_glib, docletpath, tmp_dir, pkg.name, pkg.get_vapi_path (vapidirs), Path.get_dirname (pkg.get_vapi_path (vapidirs)), girdir, pkg.flags); if (disable_devhelp == true) { builder.append (" -X --disable-devhelp"); @@ -868,9 +869,9 @@ public class Valadoc.IndexGenerator : Valadoc.ValadocOrgDoclet { } if (pkg.gallery != null) { - generate_widget_gallery (pkg); + generate_widget_gallery (pkg, tmp_dir); - builder.append (" --importdir \"tmp\""); + builder.append_printf (" --importdir \"%s\"", tmp_dir); builder.append_printf (" --import \"%s-widget-gallery\"", pkg.name); } @@ -947,7 +948,7 @@ public class Valadoc.IndexGenerator : Valadoc.ValadocOrgDoclet { } Process.spawn_command_line_sync ("rm -r -f %s".printf (Path.build_path (Path.DIR_SEPARATOR_S, output_directory, pkg.name))); - Process.spawn_command_line_sync ("mv tmp/%s/%s \"%s\"".printf (pkg.name, pkg.name, output_directory)); + Process.spawn_command_line_sync ("mv %s/%s/%s \"%s\"".printf (tmp_dir, pkg.name, pkg.name, output_directory)); } catch (SpawnError e) { stdout.printf ("ERROR: Can't generate documentation for %s.\n", pkg.name); throw e; @@ -993,7 +994,7 @@ public class Valadoc.IndexGenerator : Valadoc.ValadocOrgDoclet { } } - private void generate_widget_gallery (Package pkg) throws Error { + private void generate_widget_gallery (Package pkg, string tmp_dir) throws Error { if (pkg.gallery == null) { return ; } @@ -1005,12 +1006,12 @@ public class Valadoc.IndexGenerator : Valadoc.ValadocOrgDoclet { } string search_path = pkg.gallery.substring (0, pos); - stdout.printf (" widget gallery\n"); + var c_gallery_path = "%s/c-gallery.html".printf (tmp_dir); - if (!FileUtils.test ("tmp/c-gallery.html", FileTest.EXISTS)) { + if (!FileUtils.test (c_gallery_path, FileTest.EXISTS)) { try { - Process.spawn_command_line_sync ("wget %s -O tmp/c-gallery.html \"%s\"".printf (global_wget_flags, pkg.gallery)); + Process.spawn_command_line_sync ("wget %s -O %s \"%s\"".printf (global_wget_flags, c_gallery_path, pkg.gallery)); } catch (SpawnError e) { error (e.message); } @@ -1018,7 +1019,7 @@ public class Valadoc.IndexGenerator : Valadoc.ValadocOrgDoclet { Gee.HashMap images = new Gee.HashMap (); - var markup_reader = new Vala.MarkupReader ("tmp/c-gallery.html"); + var markup_reader = new Vala.MarkupReader (c_gallery_path); Vala.MarkupTokenType token = Vala.MarkupTokenType.START_ELEMENT; Vala.SourceLocation token_begin; Vala.SourceLocation token_end; @@ -1047,7 +1048,7 @@ public class Valadoc.IndexGenerator : Valadoc.ValadocOrgDoclet { token = markup_reader.read_token (out token_begin, out token_end); } - FileUtils.unlink ("tmp/c-gallery.html"); + FileUtils.unlink (c_gallery_path); @@ -1083,7 +1084,7 @@ public class Valadoc.IndexGenerator : Valadoc.ValadocOrgDoclet { }); - stream = FileStream.open ("tmp/%s-widget-gallery.valadoc".printf (pkg.name), "w"); + stream = FileStream.open ("%s/%s-widget-gallery.valadoc".printf (tmp_dir, pkg.name), "w"); assert (stream != null); bool first_entry = true; @@ -1303,11 +1304,6 @@ public class Valadoc.IndexGenerator : Valadoc.ValadocOrgDoclet { return -1; } - if (FileUtils.test ("tmp", FileTest.IS_DIR)) { - stdout.printf ("error: tmp already exist.\n"); - return -1; - } - if (output_directory == null) { output_directory = "valadoc.org"; } @@ -1330,12 +1326,6 @@ public class Valadoc.IndexGenerator : Valadoc.ValadocOrgDoclet { } } - if (DirUtils.create ("tmp", 0777) != 0) { - stdout.printf ("error: can't create tmp/.\n"); - return -1; - } - - int return_val = 0; try { @@ -1377,7 +1367,6 @@ public class Valadoc.IndexGenerator : Valadoc.ValadocOrgDoclet { return_val = -1; } - DirUtils.remove ("tmp"); return return_val; }