[tracker/wip/carlosg/hotdoc: 49/53] doc: Tweak hotdoc theme




commit 00b66763da546481461050ed064476704b2403a9
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Aug 5 15:13:34 2021 +0200

    doc: Tweak hotdoc theme
    
    We need to help it a bit, so it can put our ontology note icons
    side by side, and to include turtle/sparql prism components, since
    hotdoc ships an ancient version of prism for syntax highlighting
    that does not observe these formats yet.

 docs/reference/libtracker-sparql/meson.build       |  1 +
 .../theme-extra/css/tracker-custom.css             |  3 +
 .../theme-extra/prism_components/prism-sparql.js   | 65 ++++++++++++++++++++++
 .../prism_components/prism-sparql.min.js           |  1 +
 .../theme-extra/prism_components/prism-turtle.js   | 55 ++++++++++++++++++
 .../prism_components/prism-turtle.min.js           |  1 +
 6 files changed, 126 insertions(+)
---
diff --git a/docs/reference/libtracker-sparql/meson.build b/docs/reference/libtracker-sparql/meson.build
index bb24c56ba..44c1ccdcc 100644
--- a/docs/reference/libtracker-sparql/meson.build
+++ b/docs/reference/libtracker-sparql/meson.build
@@ -75,6 +75,7 @@ hotdoc.generate_doc('tracker',
   gi_c_source_roots: [sparqlinc],
   dependencies: [tracker_sparql_dep, glib, gobject],
   extra_assets: [join_paths(meson.current_source_dir(), 'images')],
+  html_extra_theme: join_paths(meson.current_source_dir(), 'theme-extra'),
   syntax_highlighting_activate: true,
   devhelp_activate: true,
   install: true,
diff --git a/docs/reference/libtracker-sparql/theme-extra/css/tracker-custom.css 
b/docs/reference/libtracker-sparql/theme-extra/css/tracker-custom.css
new file mode 100644
index 000000000..dc1ed37bf
--- /dev/null
+++ b/docs/reference/libtracker-sparql/theme-extra/css/tracker-custom.css
@@ -0,0 +1,3 @@
+#page-description img {
+  display: inherit;
+}
diff --git a/docs/reference/libtracker-sparql/theme-extra/prism_components/prism-sparql.js 
b/docs/reference/libtracker-sparql/theme-extra/prism_components/prism-sparql.js
new file mode 100644
index 000000000..691d48707
--- /dev/null
+++ b/docs/reference/libtracker-sparql/theme-extra/prism_components/prism-sparql.js
@@ -0,0 +1,65 @@
+/* Original at https://github.com/PrismJS/prism.git, under MIT license.
+ * Plus adaptions to make it work on ancient prism as used by hotdoc,
+ * and our own keywords.
+ */
+Prism.languages.sparql = {
+       'comment': {
+               pattern: /#.*/,
+               greedy: true
+       },
+       'multiline-string': {
+               pattern: /"""(?:(?:""?)?(?:[^"\\]|\\.))*"""|'''(?:(?:''?)?(?:[^'\\]|\\.))*'''/,
+               greedy: true,
+               alias: 'string',
+               inside: {
+                       'comment': /#.*/
+               }
+       },
+       'string': {
+               pattern: /"(?:[^\\"\r\n]|\\.)*"|'(?:[^\\'\r\n]|\\.)*'/,
+               greedy: true
+       },
+       'url': {
+               pattern: /<(?:[^\x00-\x20<>"{}|^`\\]|\\(?:u[\da-fA-F]{4}|U[\da-fA-F]{8}))*>/,
+               greedy: true,
+               inside: {
+                       'punctuation': /[<>]/
+               }
+       },
+       'function': {
+               pattern: 
/(?:(?![-.\d\xB7])[-.\w\xB7\xC0-\uFFFD]+)?:(?:(?![-.])(?:[-.:\w\xC0-\uFFFD]|%[\da-f]{2}|\\.)+)?/i,
+               inside: {
+                       'local-name': {
+                               pattern: /([^:]*:)[\s\S]+/,
+                               lookbehind: true
+                       },
+                       'prefix': {
+                               pattern: /[\s\S]+/,
+                               inside: {
+                                       'punctuation': /:/
+                               }
+                       }
+               }
+       },
+       'number': /[+-]?\b\d+(?:\.\d*)?(?:e[+-]?\d+)?/i,
+       'punctuation': /[{}.,;()[\]]|\^\^/,
+       'boolean': /\b(?:true|false)\b/i,
+       'keyword': [
+               
/\b(?:A|ADD|ALL|AS|ASC|ASK|BNODE|BY|CLEAR|CONSTRAINT|CONSTRUCT|COPY|CREATE|DATA|DEFAULT|DELETE|DESC|DESCRIBE|DISTINCT|DROP|EXISTS|FILTER|FROM|GROUP|HAVING|INSERT|INTO|LIMIT|LOAD|MINUS|MOVE|NAMED|NOT|NOW|OFFSET|OPTIONAL|OR|ORDER|RAND|REDUCED|REPLACE|SELECT|SEPARATOR|SERVICE|SILENT|STRUUID|UNION|USING|UUID|VALUES|WHERE)\b/i,
+               
/\b(?:ABS|AVG|BIND|BOUND|CEIL|COALESCE|CONCAT|CONTAINS|COUNT|DATATYPE|DAY|ENCODE_FOR_URI|FLOOR|GROUP_CONCAT|HOURS|IF|IRI|isBLANK|isIRI|isLITERAL|isNUMERIC|isURI|LANG|LANGMATCHES|LCASE|MAX|MD5|MIN|MINUTES|MONTH|ROUND|REGEX|REPLACE|sameTerm|SAMPLE|SECONDS|SHA1|SHA256|SHA384|SHA512|STR|STRAFTER|STRBEFORE|STRDT|STRENDS|STRLANG|STRLEN|STRSTARTS|SUBSTR|SUM|TIMEZONE|TZ|UCASE|URI|YEAR)\b(?=\s*\()/i,
+               /\b(?:GRAPH|BASE|PREFIX)\b/i,
+               /(?:\ba|@prefix|@base)\b|=/,
+               /\b(?:graph|base|prefix)\b/i
+       ],
+       'variable': {
+               pattern: /[?$]\w+/,
+               greedy: true
+       },
+       'tag': {
+               pattern: /@[a-z]+(?:-[a-z\d]+)*/i,
+               inside: {
+                       'punctuation': /@/
+               }
+       }
+};
+Prism.languages.rq = Prism.languages.sparql;
diff --git a/docs/reference/libtracker-sparql/theme-extra/prism_components/prism-sparql.min.js 
b/docs/reference/libtracker-sparql/theme-extra/prism_components/prism-sparql.min.js
new file mode 100644
index 000000000..0df615e1e
--- /dev/null
+++ b/docs/reference/libtracker-sparql/theme-extra/prism_components/prism-sparql.min.js
@@ -0,0 +1 @@
+Prism.languages.sparql={'comment':{pattern:/#.*/,greedy:true},'multiline-string':{pattern:/"""(?:(?:""?)?(?:[^"\\]|\\.))*"""|'''(?:(?:''?)?(?:[^'\\]|\\.))*'''/,greedy:true,alias:'string',inside:{'comment':/#.*/}},'string':{pattern:/"(?:[^\\"\r\n]|\\.)*"|'(?:[^\\'\r\n]|\\.)*'/,greedy:true},'url':{pattern:/<(?:[^\x00-\x20<>"{}|^`\\]|\\(?:u[\da-fA-F]{4}|U[\da-fA-F]{8}))*>/,greedy:true,inside:{'punctuation':/[<>]/}},'function':{pattern:/(?:(?![-.\d\xB7])[-.\w\xB7\xC0-\uFFFD]+)?:(?:(?![-.])(?:[-.:\w\xC0-\uFFFD]|%[\da-f]{2}|\\.)+)?/i,inside:{'local-name':{pattern:/([^:]*:)[\s\S]+/,lookbehind:true},'prefix':{pattern:/[\s\S]+/,inside:{'punctuation':/:/}}}},'number':/[+-]?\b\d+(?:\.\d*)?(?:e[+-]?\d+)?/i,'punctuation':/[{}.,;()[\]]|\^\^/,'boolean':/\b(?:true|false)\b/i,'keyword':[/\b(?:A|ADD|ALL|AS|ASC|ASK|BNODE|BY|CLEAR|CONSTRAINT|CONSTRUCT|COPY|CREATE|DATA|DEFAULT|DELETE|DESC|DESCRIBE|DISTINCT|DROP|EXISTS|FILTER|FROM|GROUP|HAVING|INSERT|INTO|LIMIT|LOAD|MINUS|MOVE|NAMED|NOT|NOW|OFFSET|OPTION
 
AL|OR|ORDER|RAND|REDUCED|REPLACE|SELECT|SEPARATOR|SERVICE|SILENT|STRUUID|UNION|USING|UUID|VALUES|WHERE)\b/i,/\b(?:ABS|AVG|BIND|BOUND|CEIL|COALESCE|CONCAT|CONTAINS|COUNT|DATATYPE|DAY|ENCODE_FOR_URI|FLOOR|GROUP_CONCAT|HOURS|IF|IRI|isBLANK|isIRI|isLITERAL|isNUMERIC|isURI|LANG|LANGMATCHES|LCASE|MAX|MD5|MIN|MINUTES|MONTH|ROUND|REGEX|REPLACE|sameTerm|SAMPLE|SECONDS|SHA1|SHA256|SHA384|SHA512|STR|STRAFTER|STRBEFORE|STRDT|STRENDS|STRLANG|STRLEN|STRSTARTS|SUBSTR|SUM|TIMEZONE|TZ|UCASE|URI|YEAR)\b(?=\s*\()/i,/\b(?:GRAPH|BASE|PREFIX)\b/i,/(?:\ba|@prefix|@base)\b|=/,/\b(?:graph|base|prefix)\b/i],'variable':{pattern:/[?$]\w+/,greedy:true},'tag':{pattern:/@[a-z]+(?:-[a-z\d]+)*/i,inside:{'punctuation':/@/}}};Prism.languages.rq=Prism.languages.sparql;
diff --git a/docs/reference/libtracker-sparql/theme-extra/prism_components/prism-turtle.js 
b/docs/reference/libtracker-sparql/theme-extra/prism_components/prism-turtle.js
new file mode 100644
index 000000000..4d588f716
--- /dev/null
+++ b/docs/reference/libtracker-sparql/theme-extra/prism_components/prism-turtle.js
@@ -0,0 +1,55 @@
+/* Original at https://github.com/PrismJS/prism.git, under MIT license */
+Prism.languages.turtle = {
+       'comment': {
+               pattern: /#.*/,
+               greedy: true
+       },
+       'multiline-string': {
+               pattern: /"""(?:(?:""?)?(?:[^"\\]|\\.))*"""|'''(?:(?:''?)?(?:[^'\\]|\\.))*'''/,
+               greedy: true,
+               alias: 'string',
+               inside: {
+                       'comment': /#.*/
+               }
+       },
+       'string': {
+               pattern: /"(?:[^\\"\r\n]|\\.)*"|'(?:[^\\'\r\n]|\\.)*'/,
+               greedy: true
+       },
+       'url': {
+               pattern: /<(?:[^\x00-\x20<>"{}|^`\\]|\\(?:u[\da-fA-F]{4}|U[\da-fA-F]{8}))*>/,
+               greedy: true,
+               inside: {
+                       'punctuation': /[<>]/
+               }
+       },
+       'function': {
+               pattern: 
/(?:(?![-.\d\xB7])[-.\w\xB7\xC0-\uFFFD]+)?:(?:(?![-.])(?:[-.:\w\xC0-\uFFFD]|%[\da-f]{2}|\\.)+)?/i,
+               inside: {
+                       'local-name': {
+                               pattern: /([^:]*:)[\s\S]+/,
+                               lookbehind: true
+                       },
+                       'prefix': {
+                               pattern: /[\s\S]+/,
+                               inside: {
+                                       'punctuation': /:/
+                               }
+                       }
+               }
+       },
+       'number': /[+-]?\b\d+(?:\.\d*)?(?:e[+-]?\d+)?/i,
+       'punctuation': /[{}.,;()[\]]|\^\^/,
+       'boolean': /\b(?:true|false)\b/,
+       'keyword': [
+               /(?:\ba|@prefix|@base)\b|=/,
+               /\b(?:graph|base|prefix)\b/i
+       ],
+       'tag': {
+               pattern: /@[a-z]+(?:-[a-z\d]+)*/i,
+               inside: {
+                       'punctuation': /@/
+               }
+       }
+};
+Prism.languages.trig = Prism.languages['turtle'];
diff --git a/docs/reference/libtracker-sparql/theme-extra/prism_components/prism-turtle.min.js 
b/docs/reference/libtracker-sparql/theme-extra/prism_components/prism-turtle.min.js
new file mode 100644
index 000000000..eaa96996e
--- /dev/null
+++ b/docs/reference/libtracker-sparql/theme-extra/prism_components/prism-turtle.min.js
@@ -0,0 +1 @@
+Prism.languages.turtle={comment:{pattern:/#.*/,greedy:!0},"multiline-string":{pattern:/"""(?:(?:""?)?(?:[^"\\]|\\.))*"""|'''(?:(?:''?)?(?:[^'\\]|\\.))*'''/,greedy:!0,alias:"string",inside:{comment:/#.*/}},string:{pattern:/"(?:[^\\"\r\n]|\\.)*"|'(?:[^\\'\r\n]|\\.)*'/,greedy:!0},url:{pattern:/<(?:[^\x00-\x20<>"{}|^`\\]|\\(?:u[\da-fA-F]{4}|U[\da-fA-F]{8}))*>/,greedy:!0,inside:{punctuation:/[<>]/}},function:{pattern:/(?:(?![-.\d\xB7])[-.\w\xB7\xC0-\uFFFD]+)?:(?:(?![-.])(?:[-.:\w\xC0-\uFFFD]|%[\da-f]{2}|\\.)+)?/i,inside:{"local-name":{pattern:/([^:]*:)[\s\S]+/,lookbehind:!0},prefix:{pattern:/[\s\S]+/,inside:{punctuation:/:/}}}},number:/[+-]?\b\d+(?:\.\d*)?(?:e[+-]?\d+)?/i,punctuation:/[{}.,;()[\]]|\^\^/,boolean:/\b(?:true|false)\b/,keyword:[/(?:\ba|@prefix|@base)\b|=/,/\b(?:graph|base|prefix)\b/i],tag:{pattern:/@[a-z]+(?:-[a-z\d]+)*/i,inside:{punctuation:/@/}}},Prism.languages.trig=Prism.languages.turtle;
\ No newline at end of file


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]