Skip to content

Commit 86abb6b

Browse files
Merge pull request #73 from cpprefjp/add_new_categories
Add new categories
2 parents 7d1b0bd + 49832ab commit 86abb6b

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

crsearch.json/run.py

Lines changed: 36 additions & 4 deletions
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,13 +127,37 @@ 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,
132157
'properties': {
133158
'type': {
134159
'type': 'string',
135-
'enum': ['class', 'function', 'mem_fun', 'macro', 'enum', 'variable', 'type-alias', 'concept', 'cpo', 'article'],
160+
'enum': ['class', 'function', 'mem_fun', 'macro', 'enum', 'variable', 'type-alias', 'concept', 'named requirement', 'cpo', 'article'],
136161
},
137162
'key': {
138163
'type': 'array',
@@ -249,13 +274,15 @@ def get_meta(self, md):
249274
@staticmethod
250275
def identify_type(metas, names, nojump):
251276
# type 判別
252-
# metas['id-type']: class, class template, function, function template, enum, variable, type-alias, concept, macro, namespace
253-
# type: "header" / "class" / "function" / "mem_fun" / "macro" / "enum" / "variable"/ "type-alias" / "concept"/ "article"
277+
# metas['id-type']: class, class template, function, function template, enum, variable, type-alias, concept, named requirement, macro, namespace
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'
@@ -280,7 +307,7 @@ def identify_type(metas, names, nojump):
280307
return 'mem_fun'
281308
else:
282309
return 'function'
283-
elif id_type in {'enum', 'variable', 'type-alias', 'concept', 'macro', 'namespace', 'cpo'}:
310+
elif id_type in {'enum', 'variable', 'type-alias', 'concept', 'named requirement', 'macro', 'namespace', 'cpo'}:
284311
return id_type
285312
else:
286313
raise RuntimeError(f'unexpected meta: {metas}')
@@ -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)