04 Nov, 2020

1 commit

  • Pull documentation fixes from Jonathan Corbet:
    "A small number of fixes, plus a build tweak to respect the desire for
    silence in V=0 builds"

    * tag 'docs-5.10-3' of git://git.lwn.net/linux:
    docs: fix automarkup regression on Python 2
    documentation: arm: sunxi: add Allwinner H6 documents
    scripts: kernel-doc: split typedef complex regex
    scripts: kernel-doc: fix typedef parsing
    docs: Makefile: honor V=0 for docs building

    Linus Torvalds
     

03 Nov, 2020

1 commit


30 Oct, 2020

7 commits

  • Now that the stable ABI files are compatible with ReST,
    parse them without converting complex descriptions as literal
    blocks nor escaping special characters.

    Please notice that escaping special characters will probably
    be needed at descriptions, at least for the asterisk character.

    Acked-by: Jonathan Corbet
    Signed-off-by: Mauro Carvalho Chehab
    Link: https://lore.kernel.org/r/59ccbaa75ff05f23e701dd9a0bbe118e9343a553.1604042072.git.mchehab+huawei@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Mauro Carvalho Chehab
     
  • The Sphinx docutils parser is lazy: if the content is bigger than
    a certain number of lines, it silenlty stops parsing it,
    producing an incomplete content. This seems to be worse on newer
    Sphinx versions, like 2.0.

    So, change the logic to parse the contents per input file.

    Acked-by: Jonathan Corbet
    Signed-off-by: Mauro Carvalho Chehab
    Link: https://lore.kernel.org/r/4659b60795739308e34d2d00c57ee0742a9cd2ab.1604042072.git.mchehab+huawei@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Mauro Carvalho Chehab
     
  • Just like kernel-doc extension, we need to be able to identify
    what part of an imported document has issues, as reporting them
    as:

    get_abi.pl rest --dir $srctree/Documentation/ABI/obsolete --rst-source:1689: ERROR: Unexpected indentation.

    Makes a lot harder for someone to fix.

    It should be noticed that it the line which will be reported is
    the line where the "What:" definition is, and not the line
    with actually has an error.

    Acked-by: Jonathan Corbet
    Signed-off-by: Mauro Carvalho Chehab
    Link: https://lore.kernel.org/r/d6155ab16fb7631f2fa8e7a770eae72f24bf7cc5.1604042072.git.mchehab+huawei@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Mauro Carvalho Chehab
     
  • The same way kerneldoc.py needed changes to work with newer
    Sphinx, this script needs the same changes.

    While here, reorganize the include order to match kerneldoc.py.

    Acked-by: Jonathan Corbet
    Signed-off-by: Mauro Carvalho Chehab
    Link: https://lore.kernel.org/r/f2b25caef5db7738629773a03463908d3b39b83a.1604042072.git.mchehab+huawei@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Mauro Carvalho Chehab
     
  • The parser breaks with UTF-8 characters with Sphinx 1.4.

    Acked-by: Jonathan Corbet
    Signed-off-by: Mauro Carvalho Chehab
    Link: https://lore.kernel.org/r/9e7c8e3b0efaa1ae0536da6493ab438bd3f9fe58.1604042072.git.mchehab+huawei@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Mauro Carvalho Chehab
     
  • The ABI documentation is special: it is not plain text files,
    but, instead, files with an strict format, as specified by
    Documentation/ABI/README.

    Add a parser for it.

    Acked-by: Jonathan Corbet
    Signed-off-by: Mauro Carvalho Chehab
    Link: https://lore.kernel.org/r/48abf1a410237e63f85354a8cd7027fdf25657bf.1604042072.git.mchehab+huawei@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Mauro Carvalho Chehab
     
  • An extension may want to just inform about something. So, add
    support for it.

    Acked-by: Jonathan Corbet
    Signed-off-by: Mauro Carvalho Chehab
    Link: https://lore.kernel.org/r/0ddebd8677605d789d53433c8a5344c68da82a73.1604042072.git.mchehab+huawei@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Mauro Carvalho Chehab
     

15 Oct, 2020

10 commits

  • The :c:type:`foo` only works properly with structs before
    Sphinx 3.x.

    On Sphinx 3.x, structs should now be declared using the
    .. c:struct, and referenced via :c:struct tag.

    As we now have the automarkup.py macro, that automatically
    convert:
    struct foo

    into cross-references, let's get rid of that, solving
    several warnings when building docs with Sphinx 3.x.

    Reviewed-by: André Almeida # blk-mq.rst
    Reviewed-by: Takashi Iwai # sound
    Reviewed-by: Mike Rapoport
    Reviewed-by: Greg Kroah-Hartman
    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     
  • Sphinx 3 added support for declaring C macros with parameters using the
    :c:macro role.

    To support automarkup for both functions and parametrized macros using
    the same regex (words ending in ()), try to cross-reference to both, and
    only fall back to regular text if neither exist.

    Signed-off-by: Nícolas F. R. A. Prado
    Signed-off-by: Mauro Carvalho Chehab

    Nícolas F. R. A. Prado
     
  • With the transition to Sphinx 3, new warnings were caused by
    automarkup, exposing bugs in the name matching.

    When automarkup parsed a text like "struct struct" in the documentation,
    it tried to cross-reference to a "struct" symbol, which is recognized as
    a C reserved word by Sphinx 3, generating a warning.

    Add some C reserved words (only the ones that were causing warnings) to
    a list and skip them while trying to cross-reference.

    Signed-off-by: Nícolas F. R. A. Prado
    Signed-off-by: Mauro Carvalho Chehab

    Nícolas F. R. A. Prado
     
  • With the transition to Sphinx 3, new warnings were generated by
    automarkup, exposing bugs in the regexes.

    The warnings were caused by the expressions matching words in the
    translated versions of the documentation, since any unicode character
    was matched.

    Fix the regular expression by making the C regexes use ASCII and
    ensuring the expressions only match the beginning of words,
    in order to avoid warnings like this:

    WARNING: Unparseable C cross-reference: '调用debugfs_rename'

    That's probably due to the lack of using spaces between words
    on Chinese.

    Signed-off-by: Nícolas F. R. A. Prado
    Signed-off-by: Mauro Carvalho Chehab

    Nícolas F. R. A. Prado
     
  • While Sphinx 2 used a single c:type role for struct, union, enum and
    typedef, Sphinx 3 uses a specific role for each one.
    To keep backward compatibility, detect the Sphinx version and use the
    correct roles for that version.

    Signed-off-by: Nícolas F. R. A. Prado
    Signed-off-by: Mauro Carvalho Chehab

    Nícolas F. R. A. Prado
     
  • Currently, there's no way to exclude identifiers from
    a kernel-doc markup. Add support for it.

    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     
  • Finding where an error like this was generated:
    ../lib/math/div64.c:73: WARNING: Duplicate C declaration, also defined in 'kernel-api'.

    Can take some time, as there's no glue about what kernel-doc
    tag generated it. It is a way better to display it as:

    .../Documentation/core-api/kernel-api:171: ../lib/math/div64.c:73: WARNING: Duplicate C declaration, also defined in 'kernel-api'.
    Declaration is 'div_s64_rem'.

    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     
  • While most of the C domain parsing is done via kernel-doc,
    some RST files use C domain tags directly.

    While several of them can be removed for Sphinx < 3.0, due
    to automarkup.py, and several others that could be
    converted into kernel-doc markups, changes like that are
    time-consuming, and may not fit all cases.

    As we already have the cdomain.py for handing backward
    compatibility with Sphinx versions below 3.0, let's
    make it more complete, in order to cover any usage of the
    newer tags outside kernel-doc.

    This way, it should be feasible to use the new tags inside
    the Kernel tree, without losing backward compatibility.

    This should allow fixing the remaining warnings with
    the Kernel tags.

    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     
  • Since Sphinx 3.0, the C domain code was rewritten, but only
    after version 3.1 it got support for setting namespaces on
    C domains, with is something that it is required, in order to
    document system calls, like ioctl() and others.

    As part of changing the documentation subsystem to properly
    build with Sphinx 3.1+, add support for such new tag:

    .. c:namespace::"

    Such tag optionally replaces the optional "name" tag for functions,
    setting a single namespace domain for all C references found
    at the file.

    With that, it should be possible to convert existing
    documentation to be compatible with both Sphinx 1.x/2.x and
    3.1+.

    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     
  • When kernel-doc is called via kerneldoc.py, there's no need to
    auto-detect the Sphinx version, as the Sphinx module already
    knows it. So, add an optional parameter to allow changing the
    Sphinx dialect.

    As kernel-doc can also be manually called, keep the auto-detection
    logic if the parameter was not specified. On such case, emit
    a warning if sphinx-build can't be found at PATH.

    I ended using a suggestion from Joe for using a more readable
    regex, instead of using a complex one with a hidden group like:

    m/^(\d+)\.(\d+)(?:\.?(\d+)?)/

    in order to get the optional argument.

    Thanks-to: Joe Perches
    Suggested-by: Jonathan Corbet
    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     

17 Sep, 2020

2 commits

  • Cross-referencing to other documentation pages is possible using the
    :doc:`doc-file` directive from Sphinx.

    Add automatic markup for references to other documentation pages in the
    format Documentation/subfolder/doc-file.rst (the extension being
    optional).
    This requires that the path be passed all the way from the Documentation
    folder, which can be longer than passing a relative path through the
    :doc: directive, but avoids the markup, making the text cleaner when
    read in plain text.

    Signed-off-by: Nícolas F. R. A. Prado
    Link: https://lore.kernel.org/r/20200911133339.327721-3-nfraprado@protonmail.com
    Signed-off-by: Jonathan Corbet

    Nícolas F. R. A. Prado
     
  • The automarkup script previously matched expressions and substituted
    them with markup to enable automatic cross-reference all in the same
    function.

    Split the expression matching iteration and the markup substitution into
    different functions to make it easier to add new regular expressions and
    functions to treat each of them.

    Signed-off-by: Nícolas F. R. A. Prado
    Link: https://lore.kernel.org/r/20200911133339.327721-2-nfraprado@protonmail.com
    Signed-off-by: Jonathan Corbet

    Nícolas F. R. A. Prado
     

04 Sep, 2020

1 commit

  • In order to cross-reference C types in the documentation, Sphinx
    requires the syntax :c:type:`type_name`, or even :c:type:`struct
    type_name ` in order to have the link text different from the
    target text.

    Extend automarkup to enable automatic cross-reference of C types by
    matching any "struct|union|enum|typedef type_name" expression.
    This makes the documentation's plain text cleaner and adds
    cross-reference to types without any additional effort by the author.

    Signed-off-by: Nícolas F. R. A. Prado
    Link: https://lore.kernel.org/r/20200903005747.3900333-2-nfraprado@protonmail.com
    Signed-off-by: Jonathan Corbet

    Nícolas F. R. A. Prado
     

27 Jun, 2020

1 commit

  • Rationale:
    Reduces attack surface on kernel devs opening the links for MITM
    as HTTPS traffic is much harder to manipulate.

    Deterministic algorithm:
    For each file:
    For each line:
    If doesn't contain `\bxmlns\b`:
    For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`:
    If both the HTTP and HTTPS versions
    return 200 OK and serve the same content:
    Replace HTTP with HTTPS.

    Signed-off-by: Alexander A. Klimov
    Link: https://lore.kernel.org/r/20200620075402.22347-1-grandmaster@al2klimov.de
    Signed-off-by: Jonathan Corbet

    Alexander A. Klimov
     

08 Jun, 2020

1 commit

  • Rationale:
    Reduces attack surface on kernel devs opening the links for MITM
    as HTTPS traffic is much harder to manipulate.

    Deterministic algorithm:
    For each file:
    For each line:
    If doesn't contain `\bxmlns\b`:
    For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`:
    If both the HTTP and HTTPS versions
    return 200 OK and serve the same content:
    Replace HTTP with HTTPS.

    Signed-off-by: Alexander A. Klimov
    Link: https://lore.kernel.org/r/20200526060544.25127-1-grandmaster@al2klimov.de
    Signed-off-by: Jonathan Corbet

    Alexander A. Klimov
     

21 Apr, 2020

1 commit

  • There are some docs that have nested tables. While this was
    always part of the spec, only Sphinx version 2.4.x can
    translate it to LaTeX.

    In other words, if someone is using a Sphinx version < 2.4,
    the LaTeX and PDF output won't work for some of the docs.

    So, it seems that it is time to raise the bar again
    for the recommented version.

    The Sphinx check script is already smart enough to keep
    working, with older versions, warning the users that
    an upgrade is recommended (and explaining how):

    Sphinx version 1.7.9
    Warning: It is recommended at least Sphinx version 2.4.4.
    Detected OS: Fedora release 31 (Thirty One).

    To upgrade Sphinx, use:

    /usr/bin/virtualenv sphinx_2.4.4
    . sphinx_2.4.4/bin/activate
    pip install -r ./Documentation/sphinx/requirements.txt

    Signed-off-by: Mauro Carvalho Chehab
    Link: https://lore.kernel.org/r/498f701c618f7d0cf5f0a37e5889ee926f7c8bf4.1586881715.git.mchehab+huawei@kernel.org
    Signed-off-by: Jonathan Corbet

    Mauro Carvalho Chehab
     

25 Feb, 2020

1 commit

  • When there was no parallelism (no top-level -j arg and a pre-1.7
    sphinx-build), the argument passed would be empty ("") instead of just
    being missing, which would (understandably) badly confuse sphinx-build.
    Fix this by removing the quotes.

    Reported-by: Rafael J. Wysocki
    Fixes: 51e46c7a4007 ("docs, parallelism: Rearrange how jobserver reservations are made")
    Cc: stable@vger.kernel.org # v5.5 only
    Signed-off-by: Kees Cook
    Signed-off-by: Jonathan Corbet

    Kees Cook
     

25 Jan, 2020

1 commit

  • Sphinx 2.1 moved sphinx.environment.NoUri into sphinx.errors; that produced
    this warning in the docs build:

    /usr/lib/python3.7/site-packages/sphinx/registry.py:473:
    RemovedInSphinx30Warning: sphinx.environment.NoUri is deprecated.

    Grab NoUri from the right place and make the warning go away. That symbol
    was only added to sphinx.errors in 2.1, so we must still import it from the
    old location when running in older versions.

    Signed-off-by: Jonathan Corbet

    Jonathan Corbet
     

23 Nov, 2019

1 commit

  • Rasmus correctly observed that the existing jobserver reservation only
    worked if no other build targets were specified. The correct approach
    is to hold the jobserver slots until sphinx has finished. To fix this,
    the following changes are made:

    - refactor (and rename) scripts/jobserver-exec to set an environment
    variable for the maximally reserved jobserver slots and exec a
    child, to release the slots on exit.

    - create Documentation/scripts/parallel-wrapper.sh which examines both
    $PARALLELISM and the detected "-jauto" logic from Documentation/Makefile
    to decide sphinx's final -j argument.

    - chain these together in Documentation/Makefile

    Suggested-by: Rasmus Villemoes
    Link: https://lore.kernel.org/lkml/eb25959a-9ec4-3530-2031-d9d716b40b20@rasmusvillemoes.dk
    Signed-off-by: Kees Cook
    Link: https://lore.kernel.org/r/20191121205929.40371-4-keescook@chromium.org
    Signed-off-by: Jonathan Corbet

    Kees Cook
     

08 Nov, 2019

1 commit


03 Oct, 2019

1 commit

  • In order to have the MAINTAINERS file visible in the rendered ReST
    output, this makes some small changes to the existing MAINTAINERS file
    to allow for better machine processing, and adds a new Sphinx directive
    "maintainers-include" to perform the rendering.

    Features include:
    - Per-subsystem reference links: subsystem maintainer entries can be
    trivially linked to both internally and external. For example:
    https://www.kernel.org/doc/html/latest/process/maintainers.html#secure-computing

    - Internally referenced .rst files are linked so they can be followed
    when browsing the resulting rendering. This allows, for example, the
    future addition of maintainer profiles to be automatically linked.

    - Field name expansion: instead of the short fields (e.g. "M", "F",
    "K"), use the indicated inline "full names" for the fields (which are
    marked with "*"s in MAINTAINERS) so that a rendered subsystem entry
    is more human readable. Email lists are additionally comma-separated.
    For example:

    SECURE COMPUTING
    Mail: Kees Cook
    Reviewer: Andy Lutomirski ,
    Will Drewry
    SCM: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git seccomp
    Status: Supported
    Files: kernel/seccomp.c include/uapi/linux/seccomp.h
    include/linux/seccomp.h tools/testing/selftests/seccomp/*
    tools/testing/selftests/kselftest_harness.h
    userspace-api/seccomp_filter
    Content regex: \bsecure_computing \bTIF_SECCOMP\b

    Signed-off-by: Kees Cook
    Signed-off-by: Jonathan Corbet

    Kees Cook
     

13 Aug, 2019

2 commits

  • With the introduction of Documentation/sphinx/automarkup.py, socket() is
    parsed as a reference to the in-kernel definition of socket. Sphinx then
    decides that struct socket is a good match, which is usually not
    intended, when the syscall is meant instead. This was observed in
    Documentation/networking/af_xdp.rst.

    Prevent socket() from being misinterpreted by adding it to the Skipfuncs
    list in automarkup.py.

    Signed-off-by: Jonathan Neuschäfer
    Reviewed-by: Mauro Carvalho Chehab
    Signed-off-by: Jonathan Corbet

    Jonathan Neuschäfer
     
  • In Python, like in C, when a comma is omitted in a list of strings, the
    two strings around the missing comma are concatenated.

    Cc: stable@vger.kernel.org # v5.2 only
    Signed-off-by: Jonathan Neuschäfer
    Reviewed-by: Mauro Carvalho Chehab
    Signed-off-by: Jonathan Corbet

    Jonathan Neuschäfer
     

19 Jul, 2019

1 commit


17 Jul, 2019

1 commit

  • Right now, for every directory that we need to have LaTeX output,
    a conf.py file is required.

    That causes an extra overhead and it is actually a hack, as
    the latex_documents line there are usually a copy of the ones
    that are there already at the main conf.py.

    So, instead, re-use the global latex_documents var, just
    adjusting the path to be relative ones.

    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     

09 Jul, 2019

1 commit

  • When using the automarkup extension with:
    make pdfdocs

    without passing an specific book, the code will raise an exception:

    File "/devel/v4l/docs/Documentation/sphinx/automarkup.py", line 86, in auto_markup
    node.parent.replace(node, markup_funcs(name, app, node))
    File "/devel/v4l/docs/Documentation/sphinx/automarkup.py", line 59, in markup_funcs
    'function', target, pxref, lit_text)
    File "/devel/v4l/docs/sphinx_2.0/lib/python3.7/site-packages/sphinx/domains/c.py", line 308, in resolve_xref
    contnode, target)
    File "/devel/v4l/docs/sphinx_2.0/lib/python3.7/site-packages/sphinx/util/nodes.py", line 450, in make_refnode
    '#' + targetid)
    File "/devel/v4l/docs/sphinx_2.0/lib/python3.7/site-packages/sphinx/builders/latex/__init__.py", line 159, in get_relative_uri
    return self.get_target_uri(to, typ)
    File "/devel/v4l/docs/sphinx_2.0/lib/python3.7/site-packages/sphinx/builders/latex/__init__.py", line 152, in get_target_uri
    raise NoUri
    sphinx.environment.NoUri

    This happens because not all references will belong to a single
    PDF/LaTeX document.

    Better to just ignore those than breaking Sphinx build.

    Fixes: d74b0d31ddde ("Docs: An initial automarkup extension for sphinx")
    Signed-off-by: Mauro Carvalho Chehab
    [jc: Narrowed the "except" and tweaked the comment]
    Signed-off-by: Jonathan Corbet

    Mauro Carvalho Chehab
     

27 Jun, 2019

1 commit


31 May, 2019

1 commit

  • As discussed at the linux-doc ML, while we'll still support
    version 1.3, it is time to recommend a more modern version.

    So, let's switch the minimal requirements to Sphinx 1.7.9,
    as it has the "-jauto" flag, with makes a lot faster when
    building documentation.

    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Jonathan Corbet

    Mauro Carvalho Chehab
     

30 May, 2019

1 commit


23 May, 2019

2 commits

  • AutoReporter is going away; recent versions of sphinx emit a warning like:

    Documentation/sphinx/kerneldoc.py:125:
    RemovedInSphinx20Warning: AutodocReporter is now deprecated.
    Use sphinx.util.docutils.switch_source_input() instead.

    Make the switch. But switch_source_input() only showed up in 1.7, so we
    have to do ugly version checks to keep things working in older versions.

    Cc: stable@vger.kernel.org
    Signed-off-by: Jonathan Corbet

    Jonathan Corbet
     
  • Recent versions of sphinx will emit messages like:

    Documentation/sphinx/kerneldoc.py:103:
    RemovedInSphinx20Warning: app.warning() is now deprecated.
    Use sphinx.util.logging instead.

    Switch to sphinx.util.logging to make this unsightly message go away.
    Alas, that interface was only added in version 1.6, so we have to add a
    version check to keep things working with older sphinxes.

    Cc: stable@vger.kernel.org
    Signed-off-by: Jonathan Corbet

    Jonathan Corbet