mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	Move our minimum Sphinx version to 1.7
As promised, drop support for some ancient sphinx releases, along with a lot of the cruft that was required to make that support work. Signed-off-by: Jonathan Corbet <corbet@lwn.net>
This commit is contained in:
		
							parent
							
								
									20ccc8dd38
								
							
						
					
					
						commit
						f546ff0c0c
					
				
					 6 changed files with 21 additions and 166 deletions
				
			
		| 
						 | 
					@ -31,7 +31,7 @@ from load_config import loadConfig
 | 
				
			||||||
# -- General configuration ------------------------------------------------
 | 
					# -- General configuration ------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# If your documentation needs a minimal Sphinx version, state it here.
 | 
					# If your documentation needs a minimal Sphinx version, state it here.
 | 
				
			||||||
needs_sphinx = '1.3'
 | 
					needs_sphinx = '1.7'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Add any Sphinx extension module names here, as strings. They can be
 | 
					# Add any Sphinx extension module names here, as strings. They can be
 | 
				
			||||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
 | 
					# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
 | 
				
			||||||
| 
						 | 
					@ -112,19 +112,12 @@ if major >= 3:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
else:
 | 
					else:
 | 
				
			||||||
    extensions.append('cdomain')
 | 
					    extensions.append('cdomain')
 | 
				
			||||||
    if major == 1 and minor < 7:
 | 
					 | 
				
			||||||
        sys.stderr.write('WARNING: Sphinx 1.7 or greater will be required as of '
 | 
					 | 
				
			||||||
                         'the 5.12 release\n')
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Ensure that autosectionlabel will produce unique names
 | 
					# Ensure that autosectionlabel will produce unique names
 | 
				
			||||||
autosectionlabel_prefix_document = True
 | 
					autosectionlabel_prefix_document = True
 | 
				
			||||||
autosectionlabel_maxdepth = 2
 | 
					autosectionlabel_maxdepth = 2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# The name of the math extension changed on Sphinx 1.4
 | 
					 | 
				
			||||||
if (major == 1 and minor > 3) or (major > 1):
 | 
					 | 
				
			||||||
extensions.append("sphinx.ext.imgmath")
 | 
					extensions.append("sphinx.ext.imgmath")
 | 
				
			||||||
else:
 | 
					 | 
				
			||||||
    extensions.append("sphinx.ext.pngmath")
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Add any paths that contain templates here, relative to this directory.
 | 
					# Add any paths that contain templates here, relative to this directory.
 | 
				
			||||||
templates_path = ['_templates']
 | 
					templates_path = ['_templates']
 | 
				
			||||||
| 
						 | 
					@ -375,71 +368,9 @@ if cjk_cmd.find("Noto Sans CJK SC") >= 0:
 | 
				
			||||||
     '''
 | 
					     '''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Fix reference escape troubles with Sphinx 1.4.x
 | 
					# Fix reference escape troubles with Sphinx 1.4.x
 | 
				
			||||||
if major == 1 and minor > 3:
 | 
					if major == 1:
 | 
				
			||||||
    latex_elements['preamble']  += '\\renewcommand*{\\DUrole}[2]{ #2 }\n'
 | 
					    latex_elements['preamble']  += '\\renewcommand*{\\DUrole}[2]{ #2 }\n'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if major == 1 and minor <= 4:
 | 
					 | 
				
			||||||
    latex_elements['preamble']  += '\\usepackage[margin=0.5in, top=1in, bottom=1in]{geometry}'
 | 
					 | 
				
			||||||
elif major == 1 and (minor > 5 or (minor == 5 and patch >= 3)):
 | 
					 | 
				
			||||||
    latex_elements['sphinxsetup'] = 'hmargin=0.5in, vmargin=1in'
 | 
					 | 
				
			||||||
    latex_elements['preamble']  += '\\fvset{fontsize=auto}\n'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Customize notice background colors on Sphinx < 1.6:
 | 
					 | 
				
			||||||
if major == 1 and minor < 6:
 | 
					 | 
				
			||||||
   latex_elements['preamble']  += '''
 | 
					 | 
				
			||||||
        \\usepackage{ifthen}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        % Put notes in color and let them be inside a table
 | 
					 | 
				
			||||||
	\\definecolor{NoteColor}{RGB}{204,255,255}
 | 
					 | 
				
			||||||
	\\definecolor{WarningColor}{RGB}{255,204,204}
 | 
					 | 
				
			||||||
	\\definecolor{AttentionColor}{RGB}{255,255,204}
 | 
					 | 
				
			||||||
	\\definecolor{ImportantColor}{RGB}{192,255,204}
 | 
					 | 
				
			||||||
	\\definecolor{OtherColor}{RGB}{204,204,204}
 | 
					 | 
				
			||||||
        \\newlength{\\mynoticelength}
 | 
					 | 
				
			||||||
        \\makeatletter\\newenvironment{coloredbox}[1]{%
 | 
					 | 
				
			||||||
	   \\setlength{\\fboxrule}{1pt}
 | 
					 | 
				
			||||||
	   \\setlength{\\fboxsep}{7pt}
 | 
					 | 
				
			||||||
	   \\setlength{\\mynoticelength}{\\linewidth}
 | 
					 | 
				
			||||||
	   \\addtolength{\\mynoticelength}{-2\\fboxsep}
 | 
					 | 
				
			||||||
	   \\addtolength{\\mynoticelength}{-2\\fboxrule}
 | 
					 | 
				
			||||||
           \\begin{lrbox}{\\@tempboxa}\\begin{minipage}{\\mynoticelength}}{\\end{minipage}\\end{lrbox}%
 | 
					 | 
				
			||||||
	   \\ifthenelse%
 | 
					 | 
				
			||||||
	      {\\equal{\\py@noticetype}{note}}%
 | 
					 | 
				
			||||||
	      {\\colorbox{NoteColor}{\\usebox{\\@tempboxa}}}%
 | 
					 | 
				
			||||||
	      {%
 | 
					 | 
				
			||||||
	         \\ifthenelse%
 | 
					 | 
				
			||||||
	         {\\equal{\\py@noticetype}{warning}}%
 | 
					 | 
				
			||||||
	         {\\colorbox{WarningColor}{\\usebox{\\@tempboxa}}}%
 | 
					 | 
				
			||||||
		 {%
 | 
					 | 
				
			||||||
	            \\ifthenelse%
 | 
					 | 
				
			||||||
	            {\\equal{\\py@noticetype}{attention}}%
 | 
					 | 
				
			||||||
	            {\\colorbox{AttentionColor}{\\usebox{\\@tempboxa}}}%
 | 
					 | 
				
			||||||
		    {%
 | 
					 | 
				
			||||||
	               \\ifthenelse%
 | 
					 | 
				
			||||||
	               {\\equal{\\py@noticetype}{important}}%
 | 
					 | 
				
			||||||
	               {\\colorbox{ImportantColor}{\\usebox{\\@tempboxa}}}%
 | 
					 | 
				
			||||||
	               {\\colorbox{OtherColor}{\\usebox{\\@tempboxa}}}%
 | 
					 | 
				
			||||||
		    }%
 | 
					 | 
				
			||||||
		 }%
 | 
					 | 
				
			||||||
	      }%
 | 
					 | 
				
			||||||
        }\\makeatother
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        \\makeatletter
 | 
					 | 
				
			||||||
        \\renewenvironment{notice}[2]{%
 | 
					 | 
				
			||||||
          \\def\\py@noticetype{#1}
 | 
					 | 
				
			||||||
          \\begin{coloredbox}{#1}
 | 
					 | 
				
			||||||
          \\bf\\it
 | 
					 | 
				
			||||||
          \\par\\strong{#2}
 | 
					 | 
				
			||||||
          \\csname py@noticestart@#1\\endcsname
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
          \\csname py@noticeend@\\py@noticetype\\endcsname
 | 
					 | 
				
			||||||
          \\end{coloredbox}
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
	\\makeatother
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
     '''
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# With Sphinx 1.6, it is possible to change the Bg color directly
 | 
					# With Sphinx 1.6, it is possible to change the Bg color directly
 | 
				
			||||||
# by using:
 | 
					# by using:
 | 
				
			||||||
#	\definecolor{sphinxnoteBgColor}{RGB}{204,255,255}
 | 
					#	\definecolor{sphinxnoteBgColor}{RGB}{204,255,255}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -236,12 +236,6 @@ class CObject(Base_CObject):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        indextext = self.get_index_text(name)
 | 
					        indextext = self.get_index_text(name)
 | 
				
			||||||
        if indextext:
 | 
					        if indextext:
 | 
				
			||||||
            if major == 1 and minor < 4:
 | 
					 | 
				
			||||||
                # indexnode's tuple changed in 1.4
 | 
					 | 
				
			||||||
                # https://github.com/sphinx-doc/sphinx/commit/e6a5a3a92e938fcd75866b4227db9e0524d58f7c
 | 
					 | 
				
			||||||
                self.indexnode['entries'].append(
 | 
					 | 
				
			||||||
                    ('single', indextext, targetname, ''))
 | 
					 | 
				
			||||||
            else:
 | 
					 | 
				
			||||||
            self.indexnode['entries'].append(
 | 
					            self.indexnode['entries'].append(
 | 
				
			||||||
                    ('single', indextext, targetname, '', None))
 | 
					                    ('single', indextext, targetname, '', None))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,17 +45,7 @@ from docutils import nodes, statemachine
 | 
				
			||||||
from docutils.statemachine import ViewList
 | 
					from docutils.statemachine import ViewList
 | 
				
			||||||
from docutils.parsers.rst import directives, Directive
 | 
					from docutils.parsers.rst import directives, Directive
 | 
				
			||||||
from docutils.utils.error_reporting import ErrorString
 | 
					from docutils.utils.error_reporting import ErrorString
 | 
				
			||||||
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# AutodocReporter is only good up to Sphinx 1.7
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
import sphinx
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Use_SSI = sphinx.__version__[:3] >= '1.7'
 | 
					 | 
				
			||||||
if Use_SSI:
 | 
					 | 
				
			||||||
from sphinx.util.docutils import switch_source_input
 | 
					from sphinx.util.docutils import switch_source_input
 | 
				
			||||||
else:
 | 
					 | 
				
			||||||
    from sphinx.ext.autodoc import AutodocReporter
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
__version__  = '1.0'
 | 
					__version__  = '1.0'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -179,16 +169,5 @@ class KernelCmd(Directive):
 | 
				
			||||||
        return node.children
 | 
					        return node.children
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def do_parse(self, content, node):
 | 
					    def do_parse(self, content, node):
 | 
				
			||||||
        if Use_SSI:
 | 
					 | 
				
			||||||
        with switch_source_input(self.state, content):
 | 
					        with switch_source_input(self.state, content):
 | 
				
			||||||
            self.state.nested_parse(content, 0, node, match_titles=1)
 | 
					            self.state.nested_parse(content, 0, node, match_titles=1)
 | 
				
			||||||
        else:
 | 
					 | 
				
			||||||
            buf  = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            self.state.memo.title_styles  = []
 | 
					 | 
				
			||||||
            self.state.memo.section_level = 0
 | 
					 | 
				
			||||||
            self.state.memo.reporter      = AutodocReporter(content, self.state.memo.reporter)
 | 
					 | 
				
			||||||
            try:
 | 
					 | 
				
			||||||
                self.state.nested_parse(content, 0, node, match_titles=1)
 | 
					 | 
				
			||||||
            finally:
 | 
					 | 
				
			||||||
                self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = buf
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,17 +42,7 @@ from docutils import nodes, statemachine
 | 
				
			||||||
from docutils.statemachine import ViewList
 | 
					from docutils.statemachine import ViewList
 | 
				
			||||||
from docutils.parsers.rst import directives, Directive
 | 
					from docutils.parsers.rst import directives, Directive
 | 
				
			||||||
from docutils.utils.error_reporting import ErrorString
 | 
					from docutils.utils.error_reporting import ErrorString
 | 
				
			||||||
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# AutodocReporter is only good up to Sphinx 1.7
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
import sphinx
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Use_SSI = sphinx.__version__[:3] >= '1.7'
 | 
					 | 
				
			||||||
if Use_SSI:
 | 
					 | 
				
			||||||
from sphinx.util.docutils import switch_source_input
 | 
					from sphinx.util.docutils import switch_source_input
 | 
				
			||||||
else:
 | 
					 | 
				
			||||||
    from sphinx.ext.autodoc import AutodocReporter
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
__version__  = '1.0'
 | 
					__version__  = '1.0'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -154,16 +144,7 @@ class KernelFeat(Directive):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        buf  = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter
 | 
					        buf  = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if Use_SSI:
 | 
					 | 
				
			||||||
        with switch_source_input(self.state, content):
 | 
					        with switch_source_input(self.state, content):
 | 
				
			||||||
            self.state.nested_parse(content, 0, node, match_titles=1)
 | 
					            self.state.nested_parse(content, 0, node, match_titles=1)
 | 
				
			||||||
        else:
 | 
					 | 
				
			||||||
            self.state.memo.title_styles  = []
 | 
					 | 
				
			||||||
            self.state.memo.section_level = 0
 | 
					 | 
				
			||||||
            self.state.memo.reporter      = AutodocReporter(content, self.state.memo.reporter)
 | 
					 | 
				
			||||||
            try:
 | 
					 | 
				
			||||||
                self.state.nested_parse(content, 0, node, match_titles=1)
 | 
					 | 
				
			||||||
            finally:
 | 
					 | 
				
			||||||
                self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = buf
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return node.children
 | 
					        return node.children
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,18 +37,8 @@ import glob
 | 
				
			||||||
from docutils import nodes, statemachine
 | 
					from docutils import nodes, statemachine
 | 
				
			||||||
from docutils.statemachine import ViewList
 | 
					from docutils.statemachine import ViewList
 | 
				
			||||||
from docutils.parsers.rst import directives, Directive
 | 
					from docutils.parsers.rst import directives, Directive
 | 
				
			||||||
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# AutodocReporter is only good up to Sphinx 1.7
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
import sphinx
 | 
					import sphinx
 | 
				
			||||||
 | 
					 | 
				
			||||||
Use_SSI = sphinx.__version__[:3] >= '1.7'
 | 
					 | 
				
			||||||
if Use_SSI:
 | 
					 | 
				
			||||||
from sphinx.util.docutils import switch_source_input
 | 
					from sphinx.util.docutils import switch_source_input
 | 
				
			||||||
else:
 | 
					 | 
				
			||||||
    from sphinx.ext.autodoc import AutodocReporter
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import kernellog
 | 
					import kernellog
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__version__  = '1.0'
 | 
					__version__  = '1.0'
 | 
				
			||||||
| 
						 | 
					@ -163,18 +153,8 @@ class KernelDocDirective(Directive):
 | 
				
			||||||
            return [nodes.error(None, nodes.paragraph(text = "kernel-doc missing"))]
 | 
					            return [nodes.error(None, nodes.paragraph(text = "kernel-doc missing"))]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def do_parse(self, result, node):
 | 
					    def do_parse(self, result, node):
 | 
				
			||||||
        if Use_SSI:
 | 
					 | 
				
			||||||
        with switch_source_input(self.state, result):
 | 
					        with switch_source_input(self.state, result):
 | 
				
			||||||
            self.state.nested_parse(result, 0, node, match_titles=1)
 | 
					            self.state.nested_parse(result, 0, node, match_titles=1)
 | 
				
			||||||
        else:
 | 
					 | 
				
			||||||
            save = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter
 | 
					 | 
				
			||||||
            self.state.memo.reporter = AutodocReporter(result, self.state.memo.reporter)
 | 
					 | 
				
			||||||
            self.state.memo.title_styles, self.state.memo.section_level = [], 0
 | 
					 | 
				
			||||||
            try:
 | 
					 | 
				
			||||||
                self.state.nested_parse(result, 0, node, match_titles=1)
 | 
					 | 
				
			||||||
            finally:
 | 
					 | 
				
			||||||
                self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter = save
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
def setup(app):
 | 
					def setup(app):
 | 
				
			||||||
    app.add_config_value('kerneldoc_bin', None, 'env')
 | 
					    app.add_config_value('kerneldoc_bin', None, 'env')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,29 +4,19 @@
 | 
				
			||||||
# only goes back to 1.6.  So here's a wrapper layer to keep around for
 | 
					# only goes back to 1.6.  So here's a wrapper layer to keep around for
 | 
				
			||||||
# as long as we support 1.4.
 | 
					# as long as we support 1.4.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 | 
					# We don't support 1.4 anymore, but we'll keep the wrappers around until
 | 
				
			||||||
 | 
					# we change all the code to not use them anymore :)
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
import sphinx
 | 
					import sphinx
 | 
				
			||||||
 | 
					 | 
				
			||||||
if sphinx.__version__[:3] >= '1.6':
 | 
					 | 
				
			||||||
    UseLogging = True
 | 
					 | 
				
			||||||
from sphinx.util import logging
 | 
					from sphinx.util import logging
 | 
				
			||||||
 | 
					
 | 
				
			||||||
logger = logging.getLogger('kerneldoc')
 | 
					logger = logging.getLogger('kerneldoc')
 | 
				
			||||||
else:
 | 
					 | 
				
			||||||
    UseLogging = False
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
def warn(app, message):
 | 
					def warn(app, message):
 | 
				
			||||||
    if UseLogging:
 | 
					 | 
				
			||||||
    logger.warning(message)
 | 
					    logger.warning(message)
 | 
				
			||||||
    else:
 | 
					 | 
				
			||||||
        app.warn(message)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
def verbose(app, message):
 | 
					def verbose(app, message):
 | 
				
			||||||
    if UseLogging:
 | 
					 | 
				
			||||||
    logger.verbose(message)
 | 
					    logger.verbose(message)
 | 
				
			||||||
    else:
 | 
					 | 
				
			||||||
        app.verbose(message)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
def info(app, message):
 | 
					def info(app, message):
 | 
				
			||||||
    if UseLogging:
 | 
					 | 
				
			||||||
    logger.info(message)
 | 
					    logger.info(message)
 | 
				
			||||||
    else:
 | 
					 | 
				
			||||||
        app.info(message)
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue