4343# The default name of the Python module:
4444DEFAULT_MODULE_NAME = 'main' # main.py
4545
46- # the directory where the rendered macros must go
47- RENDERED_MACROS_DIRNAME = '__docs_macros_rendered'
46+
4847
4948
5049
@@ -295,20 +294,7 @@ def reverse(x):
295294
296295
297296
298- @property
299- def rendered_macros_dir (self ):
300- """
301- The directory, beside the docs_dir, that contains
302- the rendered pages from the macros.
303- """
304- try :
305- r = self ._rendered_macros_dir
306- except AttributeError :
307- raise AttributeError ("Rendered macros directory is undefined" )
308- if not os .path .isdir (self ._rendered_macros_dir ):
309- raise FileNotFoundError ("Rendered macros directory is defined "
310- "but does not exists" )
311- return r
297+
312298
313299
314300 # ------------------------------------------------
@@ -378,6 +364,7 @@ def register_macros(self, items:dict):
378364 Register macros (hook for other plugins).
379365 These will be added last, and raise an exception if already present.
380366 """
367+ trace (f"Registering external macros: { list (items )} " )
381368 try :
382369 # after on_config
383370 self ._macros
@@ -393,6 +380,7 @@ def register_filters(self, items:dict):
393380 Register filters (hook for other plugins).
394381 These will be added last, and raise an exception if already present.
395382 """
383+ trace (f"Registering external filters: { list (items )} " )
396384 try :
397385 self ._filters
398386 register_items ('filter' , self .filters , items )
@@ -407,6 +395,7 @@ def register_variables(self, items:dict):
407395 Register variables (hook for other plugins).
408396 These will be added last, and raise an exception if already present.
409397 """
398+ trace (f"Registering external variables: { list (items )} " )
410399 try :
411400 # after on_config
412401 self ._variables
@@ -723,6 +712,7 @@ def on_config(self, config):
723712 From the configuration file, builds a Jinj2 environment
724713 with variables, functions and filters.
725714 """
715+ trace ("Configuring the macros environment..." )
726716 # WARNING: this is not the config argument:
727717 trace ("Macros arguments\n " , self .config )
728718 # define the variables and macros as dictionaries
@@ -770,18 +760,7 @@ def on_config(self, config):
770760 register_items ('macro' , self .macros , self ._add_macros )
771761 register_items ('filter' , self .filters , self ._add_filters )
772762
773- # Provide information:
774- trace ("Config variables:" , list (self .variables .keys ()))
775- debug ("Config variables:\n " , payload = json .dumps (self .variables ,
776- cls = CustomEncoder ))
777- if self .macros :
778- trace ("Config macros:" , list (self .macros .keys ()))
779- debug ("Config macros:" , payload = json .dumps (self .macros ,
780- cls = CustomEncoder ))
781- if self .filters :
782- trace ("Config filters:" , list (self .filters .keys ()))
783- debug ("Config filters:" , payload = json .dumps (self .filters ,
784- cls = CustomEncoder ))
763+
785764 # if len(extra):
786765 # trace("Extra variables (config file):", list(extra.keys()))
787766 # debug("Content of extra variables (config file):\n", dict(extra))
@@ -856,16 +835,26 @@ def on_config(self, config):
856835 # update environment with the custom filters:
857836 self .env .filters .update (self .filters )
858837
859- # -------------------
860- # Setup the markdown (rendered) directory
861- # -------------------
862- docs_dir = config ['docs_dir' ]
863- abs_docs_dir = os .path .abspath (docs_dir )
864- # recreate only if debug (otherewise delete):
865- recreate = get_log_level ('DEBUG' )
866- self ._rendered_macros_dir = setup_directory (abs_docs_dir ,
867- RENDERED_MACROS_DIRNAME ,
868- recreate = recreate )
838+ trace ("End of environment config" )
839+
840+ def on_pre_build (self , * , config ):
841+ """
842+ Provide information on the variables.
843+ It is put here, in case some plugin hooks into the config,
844+ after the execution of the `on_config()` of this plugin.
845+ """
846+ trace ("Config variables:" , list (self .variables .keys ()))
847+ debug ("Config variables:\n " , payload = json .dumps (self .variables ,
848+ cls = CustomEncoder ))
849+ if self .macros :
850+ trace ("Config macros:" , list (self .macros .keys ()))
851+ debug ("Config macros:" , payload = json .dumps (self .macros ,
852+ cls = CustomEncoder ))
853+ if self .filters :
854+ trace ("Config filters:" , list (self .filters .keys ()))
855+ debug ("Config filters:" , payload = json .dumps (self .filters ,
856+ cls = CustomEncoder ))
857+
869858
870859 def on_nav (self , nav , config , files ):
871860 """
0 commit comments