Both, and more:
1. g.globalDirectiveList contains a list of all known directives.
leoGlobals.py--><< define g.
globalDirectiveList >> inits this list. Any code, including plugin code can add items to the list. Not a good idea to remove items.
2. @file leoGlobals.py-->g.Directives contains lots of global functions that allow quick scanning of directives. Typically, code starts with:
aList = g.get_directives_dict_list(p)
and then filters the list. For example:
def scanAtWrapDirectives(aList, issue_error_flag=False
):
'''Scan aList for @wrap and @nowrap directives.'''
for d in aList:
if d.get('wrap') is not None:
return True
elif d.get('nowrap') is not None:
return False
return None
def scanAllAtWrapDirectives(c, p):
'''Scan p and all ancestors looking for
@wrap/@nowrap directives.
'''
if c and p:
default = c and c.config.getBool("body_pane_wraps")
aList = g.get_directives_dict_list(p)
val = g.scanAtWrapDirectives(aList)
ret = default if val is None else val
else:
ret = None
return ret
In other words, g.get_directives_dict_list does the parsing, returning a list of dicts describing the directives (in order, from p through all the parents of p). This ordered list is the way Leo handles the "inheritance" of directives.
g.get_directives_dict_list
uses g.globalDirectiveList (via g.compute_directives_re). If you update g.globalDirectiveList, the g.get_directives_dict_list method will return dicts for your new directive.
Yes, this is a bit complicated, but the complications ensure fast parsing, which is important. Take a look at these methods, and feel free to ask more questions.
Edward