MCPcopy Create free account
hub / github.com/aitjcize/cppman / process_document

Method process_document

cppman/main.py:249–285  ·  view source on GitHub ↗

callback to insert index

(self, url, content, depth)

Source from the content-addressed store, hash-verified

247 self.db_conn.close()
248
249 def process_document(self, url, content, depth):
250 """callback to insert index"""
251 print("Indexing '%s' (depth %s)..." % (url, depth))
252 name = self._extract_name(content).replace('\n', '')
253 keywords = self._extract_keywords(content)
254
255 entry = {'url': url, 'keywords': set(), 'aliases': set()}
256 self.results[name].append(entry)
257
258 for n in self._parse_title(name):
259 """ add as keyword """
260 entry["keywords"].add(n)
261
262 """ add as keyword without std:: """
263 if n.find("std::") != -1:
264 entry["keywords"].add(n.replace('std::', ''))
265
266 """ add with all keywords variations """
267 for k in keywords:
268 """ add std:: to typedef if original type is in std namespace """
269 if n.find("std::") != -1 and k.find("std::") == -1:
270 k = "std::" + k;
271
272 entry["aliases"].add((n, k))
273 prefix = _commonprefix(n, k)
274
275 if len(prefix) > 2 and prefix[-2:] == "::":
276 """ Create names and keyword without prefixes """
277 new_name = n[len(prefix):]
278 new_key = k[len(prefix):]
279 entry["aliases"].add((new_name, new_key))
280
281 if k.find("std::") != -1:
282 entry["aliases"].add(
283 (n, k.replace('std::', '')))
284
285 return True
286
287 def _results_with_unique_title(self):
288 """process crawling results and return title -> entry dictionary;

Callers

nothing calls this directly

Calls 5

_extract_nameMethod · 0.95
_extract_keywordsMethod · 0.95
_parse_titleMethod · 0.95
_commonprefixFunction · 0.85
findMethod · 0.80

Tested by

no test coverage detected