Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/ctags.py
# Copyright (C) 2015-2017 The Software Heritage developers | # Copyright (C) 2015-2017 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import subprocess | import subprocess | ||||
import json | import json | ||||
from swh.model import hashutil | from swh.model import hashutil | ||||
from .language import compute_language | |||||
from .indexer import ContentIndexer, write_to_temp | from .indexer import ContentIndexer, write_to_temp | ||||
# Options used to compute tags | # Options used to compute tags | ||||
__FLAGS = [ | __FLAGS = [ | ||||
'--fields=+lnz', # +l: language | '--fields=+lnz', # +l: language | ||||
# +n: line number of tag definition | # +n: line number of tag definition | ||||
# +z: include the symbol's kind (function, variable, ...) | # +z: include the symbol's kind (function, variable, ...) | ||||
'--sort=no', # sort output on tag name | '--sort=no', # sort output on tag name | ||||
'--links=no', # do not follow symlinks | '--links=no', # do not follow symlinks | ||||
'--output-format=json', # outputs in json | '--output-format=json', # outputs in json | ||||
] | ] | ||||
def compute_language(content): | |||||
raise NotImplementedError( | |||||
'Language detection was unreliable, so it is currently disabled. ' | |||||
'See https://forge.softwareheritage.org/D1455') | |||||
def run_ctags(path, lang=None, ctags_command='ctags'): | def run_ctags(path, lang=None, ctags_command='ctags'): | ||||
"""Run ctags on file path with optional language. | """Run ctags on file path with optional language. | ||||
Args: | Args: | ||||
path: path to the file | path: path to the file | ||||
lang: language for that path (optional) | lang: language for that path (optional) | ||||
Yields: | Yields: | ||||
▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines |