Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -44,7 +46,9 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true

- name: Install the dependencies
run: |
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
8 changes: 8 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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


#
Expand Down
1 change: 1 addition & 0 deletions extra-vapis
Submodule extra-vapis added at a53319
1 change: 1 addition & 0 deletions girs
Submodule girs added at 167d36
156 changes: 156 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -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',
]
)
3 changes: 3 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -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')
37 changes: 13 additions & 24 deletions src/generator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 ;
}
Expand All @@ -1005,20 +1006,20 @@ 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);
}
}

Gee.HashMap<string, string> images = new Gee.HashMap<string, string> ();

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;
Expand Down Expand Up @@ -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);



Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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";
}
Expand All @@ -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 {
Expand Down Expand Up @@ -1377,7 +1367,6 @@ public class Valadoc.IndexGenerator : Valadoc.ValadocOrgDoclet {
return_val = -1;
}

DirUtils.remove ("tmp");
return return_val;
}

Expand Down