Skip to content
Snippets Groups Projects
Commit 0e91c720 authored by ale's avatar ale
Browse files

Add custom output styling for ecopilot_srcindex

parent 435cffec
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,34 @@ Tag = namedtuple("Tag", "rel_fname fname line name kind".split()) ...@@ -28,6 +28,34 @@ Tag = namedtuple("Tag", "rel_fname fname line name kind".split())
SQLITE_ERRORS = (sqlite3.OperationalError, sqlite3.DatabaseError, OSError) SQLITE_ERRORS = (sqlite3.OperationalError, sqlite3.DatabaseError, OSError)
# Provide custom output styling.
class MyTreeContext(TreeContext):
def format(self):
if not self.show_lines:
return ""
# output = "```\n"
output = ""
dots = not (0 in self.show_lines)
for i, line in enumerate(self.lines):
if i not in self.show_lines:
if dots:
output += "\n...\n\n"
dots = False
continue
line_output = f"{self.output_lines.get(i, line)}"
output += line_output + "\n"
dots = True
# output += "```\n"
return output
class RepoMap: class RepoMap:
CACHE_VERSION = 3 CACHE_VERSION = 3
TAGS_CACHE_DIR = f".ecopilot.tags.cache.v{CACHE_VERSION}" TAGS_CACHE_DIR = f".ecopilot.tags.cache.v{CACHE_VERSION}"
...@@ -634,7 +662,7 @@ class RepoMap: ...@@ -634,7 +662,7 @@ class RepoMap:
if not code.endswith("\n"): if not code.endswith("\n"):
code += "\n" code += "\n"
context = TreeContext( context = MyTreeContext(
rel_fname, rel_fname,
code, code,
color=False, color=False,
...@@ -691,7 +719,7 @@ class RepoMap: ...@@ -691,7 +719,7 @@ class RepoMap:
lois.append(tag.line) lois.append(tag.line)
# truncate long lines, in case we get minified js or something else crazy # truncate long lines, in case we get minified js or something else crazy
output = "\n".join([line[:100] for line in output.splitlines()]) + "\n" output = "\n".join([line[:120] for line in output.splitlines()]) + "\n"
return output return output
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment