Commits

Georg Brandl  committed 9ce528f

Activate oldcmarkup by default, but warn when the markup is used.

  • Participants
  • Parent commits b347bac

Comments (0)

Files changed (3)

   - JavaScript
   - reStructuredText
 
-* The old markup for defining and linking to C directives will not work
-  anymore without activating the :mod:`~sphinx.ext.oldcmarkup`
-  extension.
+* The old markup for defining and linking to C directives is now
+  deprecated.  It will not work anymore in future versions without
+  activating the :mod:`~sphinx.ext.oldcmarkup` extension; in Sphinx
+  1.0, it is activated by default.
 
 * Removed support for old dependency versions; requirements are now:
 

File sphinx/application.py

         if self.confdir is None:
             self.confdir = self.srcdir
 
-        # load all extension modules
+        # backwards compatibility: activate old C markup
+        self.setup_extension('sphinx.ext.oldcmarkup')
+        # load all user-given extension modules
         for extension in self.config.extensions:
             self.setup_extension(extension)
         # the config file itself can be an extension

File sphinx/ext/oldcmarkup.py

 
 from sphinx.util.compat import Directive
 
+_warned_oldcmarkup = False
+WARNING_MSG = 'using old C markup; please migrate to new-style markup ' \
+              '(e.g. c:function instead of cfunction), see ' \
+              'http://sphinx.pocoo.org/domains.html'
 
 class OldCDirective(Directive):
     has_content = True
 
     def run(self):
         env = self.state.document.settings.env
+        if not env.app._oldcmarkup_warned:
+            env.warn(env.docname, WARNING_MSG, self.lineno)
+            env.app._oldcmarkup_warned = True
         newname = 'c:' + self.name[1:]
         newdir = env.lookup_domain_element('directive', newname)[0]
         return newdir(newname, self.arguments, self.options,
 
 def old_crole(typ, rawtext, text, lineno, inliner, options={}, content=[]):
     env = inliner.document.settings.env
+    if not env.app._oldcmarkup_warned:
+        env.warn(env.docname, WARNING_MSG)
+        env.app._oldcmarkup_warned = True
     newtyp = 'c:' + typ[1:]
     newrole = env.lookup_domain_element('role', newtyp)[0]
     return newrole(newtyp, rawtext, text, lineno, inliner, options, content)
 
 
 def setup(app):
+    app._oldcmarkup_warned = False
     app.add_directive('cfunction', OldCDirective)
     app.add_directive('cmember', OldCDirective)
     app.add_directive('cmacro', OldCDirective)