Merge pull request #171 from MaximeChretien/defconfigs

http/filters: Add links to Kconfig in defconfig files
This commit is contained in:
Michael Opdenacker 2020-06-25 18:25:56 +02:00 committed by GitHub
commit 04c2458710
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 2 deletions

View file

@ -2,3 +2,4 @@
exec(open('kconfig.py').read())
exec(open('kconfigidents.py').read())
exec(open('defconfig.py').read())

23
http/filters/defconfig.py Normal file
View file

@ -0,0 +1,23 @@
# Filter for kconfig identifier in defconfigs
defconfigidents = []
def keep_defconfigidents(m):
defconfigidents.append(m.group(1))
return '__KEEPDEFCONFIGIDENTS__' + encode_number(len(defconfigidents))
def replace_defconfigidents(m):
i = defconfigidents[decode_number(m.group(1)) - 1]
return '<a href="'+version+'/K/ident/'+i+'">'+i+'</a>'
defconfigident_filters = {
'case': 'filename_extension',
'match': {'defconfig'},
'prerex': '(CONFIG_[\w]+)',
'prefunc': keep_defconfigidents,
'postrex': '__KEEPDEFCONFIGIDENTS__([A-J]+)',
'postfunc': replace_defconfigidents
}
filters.append(defconfigident_filters)

View file

@ -284,7 +284,8 @@ if mode == 'source':
if (c == 'any' or
(c == 'filename' and filename in f['match']) or
(c == 'extension' and extension in f['match']) or
(c == 'path' and fdir.startswith(tuple(f['match'])))):
(c == 'path' and fdir.startswith(tuple(f['match']))) or
(c == 'filename_extension' and filename.endswith(tuple(f['match'])))):
apply_filter = True
@ -314,7 +315,8 @@ if mode == 'source':
if (c == 'any' or
(c == 'filename' and filename in f['match']) or
(c == 'extension' and extension in f['match']) or
(c == 'path' and fdir.startswith(tuple(f['match'])))):
(c == 'path' and fdir.startswith(tuple(f['match']))) or
(c == 'filename_extension' and filename.endswith(tuple(f['match'])))):
result = sub(f ['postrex'], f ['postfunc'], result)