Commits

Georg Brandl  committed 1fcbfd8

#303: ``html_context`` values given on the command line via ``-A``
should not override other values given in conf.py.

  • Participants
  • Parent commits 5d775f3

Comments (0)

Files changed (5)

 Release 0.6.4 (in development)
 ==============================
 
+* #303: ``html_context`` values given on the command line via ``-A``
+  should not override other values given in conf.py.
+
 * Fix a bug preventing incremental rebuilds for the ``dirhtml``
   builder.
 

File sphinx/cmdline.py

     error = sys.stderr
     warnfile = None
     confoverrides = {}
-    htmlcontext = {}
     tags = []
     doctreedir = path.join(outdir, '.doctrees')
     for opt, val in opts:
                 val = int(val)
             except ValueError:
                 pass
-            htmlcontext[key] = val
+            confoverrides['html_context.%s' % key] = val
         elif opt == '-N':
             nocolor()
         elif opt == '-E':
             warnfile = val
         elif opt == '-P':
             use_pdb = True
-    confoverrides['html_context'] = htmlcontext
 
     if warning and warnfile:
         warnfp = open(warnfile, 'w')

File tests/root/_templates/layout.html

 {% extends "!layout.html" %}
 {% block extrahead %}
+{# html_context variable from conf.py #}
 <meta name="hc" content="{{ hckey }}" />
+{# html_context variable from confoverrides (as if given on cmdline) #}
+<meta name="hc_co" content="{{ hckey_co }}" />
 {{ super() }}
 {% endblock %}

File tests/root/conf.py

 html_style = 'default.css'
 html_static_path = ['_static']
 html_last_updated_fmt = '%b %d, %Y'
-html_context = {'hckey': 'hcval'}
+html_context = {'hckey': 'hcval', 'hckey_co': 'wrong_hcval_co'}
 
 htmlhelp_basename = 'SphinxTestsdoc'
 

File tests/test_build.py

     },
     'contents.html': {
         ".//meta[@name='hc'][@content='hcval']": '',
+        ".//meta[@name='hc_co'][@content='hcval_co']": '',
         ".//meta[@name='testopt'][@content='testoverride']": '',
         #".//td[@class='label']": r'\[Ref1\]',   # docutils 0.5 only
         ".//td[@class='label']": '',
                            [node.text for node in nodes]))
 
 @gen_with_app(buildername='html', warning=html_warnfile, cleanenv=True,
+              confoverrides={'html_context.hckey_co': 'hcval_co'},
               tags=['testtag'])
 def test_html(app):
     app.builder.build_all()