From f774310c22e3799dfd1ad9c4f55c6df49e808e1d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 8 Oct 2020 12:17:31 +0200 Subject: [PATCH] documentation/python: define an environment variable when generating. I need that for some REALLY DIRTY hacks. --- doc/documentation/python.rst | 7 +++++++ documentation/python.py | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/doc/documentation/python.rst b/doc/documentation/python.rst index 4476a384..b7762430 100644 --- a/doc/documentation/python.rst +++ b/doc/documentation/python.rst @@ -505,6 +505,13 @@ option: 'fastmath._native': 'fastmath' } +.. block-warning:: Overrides based an environment variable + + When m.css is run, an environment variable named + :sh:`$MCSS_GENERATING_OUTPUT` is set. This can be used for *really dirty* + hacks when monkey-patching imported modules is not enough (for example in + order to change behavior inside native modules). + `Docstrings`_ ------------- diff --git a/documentation/python.py b/documentation/python.py index 0c750426..48b0bd6f 100755 --- a/documentation/python.py +++ b/documentation/python.py @@ -2677,6 +2677,14 @@ if __name__ == '__main__': # pragma: no cover parser.add_argument('--debug', help="verbose debug output", action='store_true') args = parser.parse_args() + # Set an environment variable indicating m.css is being run. This can be + # used for REALLY DIRTY hacks when monkey-patching imported modules is not + # enough (for example in order to change behavior inside native modules and + # such) + # + # Since this is done here in __main__, it can't be checked by a test. + os.environ['MCSS_GENERATING_OUTPUT'] = '1' + # Load configuration from a file, update the defaults with it config = copy.deepcopy(default_config) name, _ = os.path.splitext(os.path.basename(args.conf)) -- 2.30.2