summaryrefslogtreecommitdiff
path: root/dev-libs/appstream/files/appstream-0.12.11-no-highlight.js.patch
blob: 66b388061a456f62f1649b1a0693dfc25903eba3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
From 5ddf424d9b5713bd71c34b5ab6bbd10ad7b74bbc Mon Sep 17 00:00:00 2001
From: Matthias Klumpp <matthias@tenstral.net>
Date: Tue, 12 May 2020 20:00:19 +0200
Subject: [PATCH] Never ship with an embedded convenience copy of Highlight.js

This should make Debian happy.
---
 docs/doc-build-helper.py                 | 10 +-------
 docs/meson.build                         | 12 ++++++++++
 docs/style/static/js/HighlightJS.LICENSE | 29 ------------------------
 docs/style/static/js/INFO.md             |  8 +++++++
 4 files changed, 21 insertions(+), 38 deletions(-)
 delete mode 100644 docs/style/static/js/HighlightJS.LICENSE
 create mode 100644 docs/style/static/js/INFO.md

diff --git a/docs/doc-build-helper.py b/docs/doc-build-helper.py
index ce46303d..c29cce2d 100755
--- a/docs/doc-build-helper.py
+++ b/docs/doc-build-helper.py
@@ -29,10 +29,6 @@
 from pathlib import Path
 
 
-# additional JavaScript from system locations, we use it if available
-EXTRA_JS = [['/usr/share/javascript/highlight.js/highlight.min.js',
-             'highlight.min.js']]
-
 # additional CSS from system locations, we use it if available
 EXTRA_CSS = [['/usr/share/javascript/highlight.js/styles/routeros.css',
               'highlight.css']]
@@ -64,11 +60,7 @@ def daps_build(src_dir, project_name, daps_exe):
     shutil.copy(os.path.join(src_dir, 'images', 'src', 'svg', 'appstream-logo.svg'),
                 os.path.join(html_out_dir, 'images'))
 
-    # copy extra JS and CSS if it is available
-    for js_fname in EXTRA_JS:
-        if os.path.exists(js_fname[0]):
-            shutil.copy(js_fname[0], os.path.join(html_out_dir, 'static',
-                                                  'js', js_fname[1]))
+    # copy extra CSS if it is available
     for css_fname in EXTRA_CSS:
         if os.path.exists(css_fname[0]):
             shutil.copy(css_fname[0], os.path.join(html_out_dir, 'static',
diff --git a/docs/meson.build b/docs/meson.build
index 1ae5fc46..d4543fdd 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -101,6 +101,12 @@ if get_option('docs')
 
     if get_option('install-docs')
         install_subdir('html', install_dir: as_doc_target_dir)
+
+        meson.add_install_script('sh', '-c',
+                          'if [ -f "@0@" ]; then mkdir -p $DESTDIR/@1@ && ln -sf @0@ $DESTDIR/@1@; fi'
+                          .format('/usr/share/javascript/highlight.js/highlight.min.js',
+                                  join_paths(get_option('prefix'), as_doc_target_dir, 'html', 'static', 'js'))
+        )
     endif
 
     # add an extra testcase for documentation validation
@@ -114,5 +120,11 @@ elif get_option('install-docs')
     if run_command('[', '-d', join_paths(meson.current_source_dir(), 'html'), ']').returncode() == 0
         # install documentation, if it exists
         install_subdir('html', install_dir: as_doc_target_dir)
+
+        meson.add_install_script('sh', '-c',
+                          'if [ -f "@0@" ]; then mkdir -p $DESTDIR/@1@ && ln -sf @0@ $DESTDIR/@1@; fi'
+                          .format('/usr/share/javascript/highlight.js/highlight.min.js',
+                                  join_paths(get_option('prefix'), as_doc_target_dir, 'html', 'static', 'js'))
+        )
     endif
 endif
diff --git a/docs/style/static/js/INFO.md b/docs/style/static/js/INFO.md
new file mode 100644
index 00000000..6e95673b
--- /dev/null
+++ b/docs/style/static/js/INFO.md
@@ -0,0 +1,8 @@
+### AppStream Documentation JS Directory
+
+You can place a minified copy of [Highlight.js](https://highlightjs.org/) in this
+directory to enable source-code highlighting in the documentation.
+
+In case a system-wide copy of `highlight.min.js` and its CSS files exists in
+`/usr/share/javascript/highlight.js/`, the buildsystem will automatically detect that
+and create symbolic links to these files when installing the documentation.