This repository has been archived by the owner on Apr 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
generate_docs_inv.py
executable file
·60 lines (54 loc) · 1.91 KB
/
generate_docs_inv.py
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Python Script to generate inventory file for docs.gmt-china.org
#
# http://pvbookmarks.readthedocs.org/en/master/devel/documentation/doc_generators/sphinx/rest_sphinx/hyperlinks.html
#
import zlib
inventory_header = '''\
# Sphinx inventory version 2
# Project: GMT
# Version: 5.4.5
# The remainder of this file is compressed with zlib.
'''.encode('utf-8')
docs = {
'configurations': 'conf',
'embellishments': 'basis/embellishments',
'grid-data': 'io/grid-data',
'vectors': 'basis/vectors',
'cpt': 'io/cpt',
'text': 'basis/text',
'character-escape': 'basis/character-escape',
'special-fonts': 'basis/special-fonts',
'special-characters': 'basis/special-characters',
'anchors': 'basis/anchors',
'pen': 'basis/pen',
'lines': 'basis/lines',
'fill': 'basis/fill',
'unit': 'basis/unit',
'option-binary': 'option/binary',
'option-n': 'option/n'
}
payload_list = []
for key, value in docs.items():
payload_list.append('{0} std:label -1 {1} {0}\n'.format(key, value))
inventory_payload = ''.join(payload_list).encode('utf-8')
# inventory_payload lines spec:
# name domainname:type priority uri dispname
#
# * `name` -- fully qualified name
# * `dispname` -- name to display when searching/linking
# * `type` -- object type, a key in ``self.object_types``
# * `docname` -- the document where it is to be found
# * `anchor` -- the anchor name for the object
# * `priority` -- how "important" the object is
# (determines placement in search results)
#
# - 1: default priority (placed before full-text matches)
# - 0: object is important (placed before default-priority objects)
# - 2: object is unimportant (placed after full-text matches)
# - -1: object should not show up in search at all
#
inventory = inventory_header + zlib.compress(inventory_payload)
open('source/docs.inv', 'wb').write(inventory)