Skip to content

Commit 49832ab

Browse files
committed
add category
1 parent 75559ad commit 49832ab

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

crsearch.json/run.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class Validator(object):
9999
'type': 'object',
100100
'oneOf': [
101101
{'$ref': '#/definitions/header'},
102+
{'$ref': '#/definitions/category'},
102103
{'$ref': '#/definitions/common'},
103104
],
104105
},
@@ -126,6 +127,30 @@ class Validator(object):
126127
},
127128
},
128129
},
130+
'category': {
131+
'require': ['type', 'key'],
132+
'additionalProperties': False,
133+
'properties': {
134+
'type': {
135+
'type': 'string',
136+
'enum': ['category'],
137+
},
138+
'key': {
139+
'type': 'array',
140+
'items': {
141+
'type': 'string',
142+
'pattern': '^[^"<>]+$',
143+
},
144+
},
145+
'cpp_namespace': {
146+
'type': 'array',
147+
'items': {
148+
'type': 'string',
149+
'pattern': '^[^:]+$',
150+
},
151+
},
152+
},
153+
},
129154
'common': {
130155
'require': ['type', 'key'],
131156
'additionalProperties': False,
@@ -250,12 +275,14 @@ def get_meta(self, md):
250275
def identify_type(metas, names, nojump):
251276
# type 判別
252277
# metas['id-type']: class, class template, function, function template, enum, variable, type-alias, concept, named requirement, macro, namespace
253-
# type: "header" / "class" / "function" / "mem_fun" / "macro" / "enum" / "variable"/ "type-alias" / "concept" / "named requirement" / "article"
278+
# type: "header" / "category" / "class" / "function" / "mem_fun" / "macro" / "enum" / "variable"/ "type-alias" / "concept" / "named requirement" / "article"
254279
if nojump:
255280
return 'meta'
256281
elif 'id-type' not in metas:
257282
if 'header' in metas:
258283
return 'header'
284+
elif 'category' in metas:
285+
return 'category'
259286
elif names[0] == 'article':
260287
# それ以外の article/ の下は article 扱いにする
261288
return 'article'
@@ -327,6 +354,11 @@ def make_index(self, md, names, idgen, nojump):
327354
'type': 'header',
328355
'key': metas['header'][0].split('/'),
329356
}))
357+
if 'category' in metas:
358+
related_to.append(idgen.get_indexid({
359+
'type': 'category',
360+
'key': metas['category'][0].split('/'),
361+
}))
330362

331363
if len(related_to) != 0:
332364
index['related_to'] = related_to

0 commit comments

Comments
 (0)