Documentation/sphinx/kerneldoc-preamble.sty

Source file repositories/reference/linux-study-clean/Documentation/sphinx/kerneldoc-preamble.sty

File Facts

System
Linux kernel
Corpus path
Documentation/sphinx/kerneldoc-preamble.sty
Extension
.sty
Size
9598 bytes
Lines
235
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: Documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

% -*- coding: utf-8 -*-
% SPDX-License-Identifier: GPL-2.0
%
% LaTeX preamble for "make latexdocs" or "make pdfdocs" including:
%   - TOC width settings
%   - Setting of tabulary (\tymin)
%   - Headheight setting for fancyhdr
%   - Fontfamily settings for CJK (Chinese, Japanese, and Korean) translations
%
% Note on the suffix of .sty:
%   This is not implemented as a LaTeX style file, but as a file containing
%   plain LaTeX code to be included into preamble.
%   ".sty" is chosen because ".tex" would cause the build scripts to confuse
%   this file with a LaTeX main file.
%
% Copyright (C) 2022  Akira Yokosawa

% Custom width parameters for TOC
%  - Redefine low-level commands defined in report.cls.
%  - Indent of 2 chars is preserved for ease of comparison.
% Summary of changes from default params:
%   Width of page number (\@pnumwidth): 1.55em -> 2.7em
%   Width of chapter number:            1.5em  -> 2.4em
%   Indent of section number:           1.5em  -> 2.4em
%   Width of section number:            2.6em  -> 3.2em
%   Indent of subsection number:        4.1em  -> 5.6em
%   Width of subsection number:         3.5em  -> 4.3em
%
% These params can have 4 digit page counts, 3 digit chapter counts,
% section counts of 4 digits + 1 period (e.g., 18.10), and subsection counts
% of 5 digits + 2 periods (e.g., 18.7.13).
\makeatletter
%% Redefine \@pnumwidth (page number width)
\renewcommand*\@pnumwidth{2.7em}
%% Redefine \l@chapter (chapter list entry)
\renewcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{2.4em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\hfil
      \nobreak\hb@xt@\@pnumwidth{\hss #2%
                                 \kern-\p@\kern\p@}\par
      \penalty\@highpenalty
    \endgroup
  \fi}
%% Redefine \l@section and \l@subsection
\renewcommand*\l@section{\@dottedtocline{1}{2.4em}{3.2em}}
\renewcommand*\l@subsection{\@dottedtocline{2}{5.6em}{4.3em}}
\makeatother
%% Prevent default \sphinxtableofcontentshook from overwriting above tweaks.
\renewcommand{\sphinxtableofcontentshook}{} % Empty the hook

% Prevent column squeezing of tabulary.  \tymin is set by Sphinx as:
%   \setlength{\tymin}{3\fontcharwd\font`0 }
% , which is too short.
\setlength{\tymin}{20em}

% Adjust \headheight for fancyhdr
\addtolength{\headheight}{1.6pt}
\addtolength{\topmargin}{-1.6pt}

% Translations have Asian (CJK) characters which are only displayed if
% xeCJK is used

Annotation

Implementation Notes