aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorGöktürk Yüksek <gokturk@gentoo.org>2019-12-18 23:05:23 -0500
committerGöktürk Yüksek <gokturk@gentoo.org>2019-12-19 15:57:56 -0500
commitbcca1643a8a6704b26e2bfb990c2e830f0006ff9 (patch)
treec950036bc12b0d6cbf42b93e3fc696ac8427104b /bin
parentMakefile: do not blindly overwrite documents.js (diff)
downloaddevmanual-bcca1643a8a6704b26e2bfb990c2e830f0006ff9.tar.gz
devmanual-bcca1643a8a6704b26e2bfb990c2e830f0006ff9.tar.bz2
devmanual-bcca1643a8a6704b26e2bfb990c2e830f0006ff9.zip
rename search_index.py to build_search_documents.py, and move it to bin/
Executables go to bin/ Also, the name is misleading. The script does not build the search index, it builds the documents for the search engine to create the index. Signed-off-by: Göktürk Yüksek <gokturk@gentoo.org>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/build_search_documents.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/bin/build_search_documents.py b/bin/build_search_documents.py
new file mode 100755
index 0000000..9af2753
--- /dev/null
+++ b/bin/build_search_documents.py
@@ -0,0 +1,24 @@
+#!/usr/bin/python
+# Copyright 2019 Gentoo Authors
+# Distributed under the terms of the GNU GPL version 2 or later
+import json
+import os.path
+import sys
+import xml.etree.ElementTree as ET
+
+files = sys.argv[1:]
+documents = []
+url_root = 'https://devmanual.gentoo.org/'
+
+for f in files:
+ tree = ET.parse(f)
+ root = tree.getroot()
+ for chapter in root.findall('chapter'):
+ try:
+ documents.append({"name": chapter.find('title').text,
+ "text": chapter.find('body').find('p').text,
+ "url": url_root + os.path.dirname(f) + '/'})
+ except AttributeError:
+ pass
+
+print('var documents = ' + json.dumps(documents) + ';')