Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move prefix_path arg to CppPathIncFilter
  • Loading branch information
nplanelcisco committed Apr 28, 2025
commit f7feb34bc6aaa7702f2499346cb6a1170653a87c
5 changes: 4 additions & 1 deletion elixir/filters/cpppathinc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
from typing import List
from .utils import Filter, FilterContext, encode_number, decode_number, extension_matches

# Filters for cpp includes like these:
Expand All @@ -8,8 +9,10 @@
# If we make references to other projects, we could
# end up with links to headers which are outside the project
# Example: u-boot/v2023.10/source/env/embedded.c#L16
# prefix_path: a list of paths, will be used to replace the prefix path during the untransform_formatted_code step
class CppPathIncFilter(Filter):
def __init__(self, *args, **kwargs):
def __init__(self, prefix_path: List[str] = ["include"], *args, **kwargs):
self.prefix_path = prefix_path
super().__init__(*args, **kwargs)
self.cpppathinc = []

Expand Down
4 changes: 1 addition & 3 deletions elixir/filters/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ class FilterContext:
# up to the filter, but it's important to be careful to not break formatting.
# The second part runs on HTML, replacing markings left by the first part with HTML code.
# path_exceptions: list of regexes, disables filter if path of the filtered file matches a regex from the list
# prefix_path: a list of paths, will be used to replace the prefix path during the untransform_formatted_code step
class Filter:
def __init__(self, path_exceptions: List[str] = [], prefix_path: List[str] = ["include"]):
def __init__(self, path_exceptions: List[str] = []):
self.path_exceptions = path_exceptions
self.prefix_path = prefix_path

# Return True if filter can be applied to file with path
def check_if_applies(self, ctx: FilterContext) -> bool:
Expand Down