Skip to content
Snippets Groups Projects
  1. Dec 03, 2020
  2. Nov 13, 2020
  3. Oct 28, 2020
  4. Oct 15, 2020
    • Mauro Carvalho Chehab's avatar
      scripts: kernel-doc: try to use c:function if possible · 6e9e4158
      Mauro Carvalho Chehab authored
      There are a few namespace clashes by using c:macro everywhere:
      
      basically, when using it, we can't have something like:
      
      	.. c:struct:: pwm_capture
      
      	.. c:macro:: pwm_capture
      
      So, we need to use, instead:
      
      	.. c:function:: int pwm_capture (struct pwm_device * pwm, struct pwm_capture * result, unsigned long timeout)
      
      for the function declaration.
      
      The kernel-doc change was proposed by Jakob Lykke Andersen here:
      
      	https://github.com/jakobandersen/linux_docs/commit/6fd2076ec001cca7466857493cd678df4dfe4a65
      
      
      
      Although I did a different implementation.
      
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      6e9e4158
    • Mauro Carvalho Chehab's avatar
      scripts: kernel-doc: fix line number handling · 5ef09c96
      Mauro Carvalho Chehab authored
      
      Address several issues related to pointing to the wrong line
      number:
      
      1) ensure that line numbers will always be initialized
      
         When section is the default (Description), the line number
         is not initializing, producing this:
      
      	$ ./scripts/kernel-doc --enable-lineno ./drivers/media/v4l2-core/v4l2-mem2mem.c|less
      
      	**Description**
      
      	#define LINENO 0
      	In case of streamoff or release called on any context,
      	1] If the context is currently running, then abort job will be called
      	2] If the context is queued, then the context will be removed from
      	   the job_queue
      
        Which is not right. Ensure that the line number will always
        be there. After applied, the result now points to the right location:
      
      	**Description**
      
      	#define LINENO 410
      	In case of streamoff or release called on any context,
      	1] If the context is currently running, then abort job will be called
      	2] If the context is queued, then the context will be removed from
      	   the job_queue
      
      2) The line numbers for function prototypes are always + 1,
         because it is taken at the line after handling the prototype.
         Change the logic to point to the next line after the /** */
         block;
      
      3) The "DOC:" line number should point to the same line as this
         markup is found, and not to the next one.
      
      Probably part of the issues were due to a but that was causing
      the line number offset to be incremented by one, if --export
      were used.
      
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      5ef09c96
    • Mauro Carvalho Chehab's avatar
      scripts: kernel-doc: allow passing desired Sphinx C domain dialect · 93351d41
      Mauro Carvalho Chehab authored
      
      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 <patch> argument.
      
      Thanks-to: Joe Perches <joe@perches.com>
      Suggested-by: default avatarJonathan Corbet <corbet@lwn.net>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      93351d41
    • Mauro Carvalho Chehab's avatar
      scripts: kernel-doc: don't mangle with parameter list · ed8348e2
      Mauro Carvalho Chehab authored
      
      While kernel-doc needs to parse parameters in order to
      identify its name, it shouldn't be touching the type,
      as parsing it is very difficult, and errors happen.
      
      One current error is when parsing this parameter:
      
      	const u32 (*tab)[256]
      
      Found at ./lib/crc32.c, on this function:
      
      	u32 __pure crc32_be_generic (u32 crc, unsigned char const *p, size_t len, const u32 (*tab)[256], u32 polynomial);
      
      The current logic mangles it, producing this output:
      
      	const u32 ( *tab
      
      That's something that it is not recognizeable.
      
      So, instead, let's push the argument as-is, and use it
      when printing the function prototype and when describing
      each argument.
      
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      ed8348e2
    • Mauro Carvalho Chehab's avatar
      scripts: kernel-doc: fix typedef identification · 47bcacfd
      Mauro Carvalho Chehab authored
      
      Some typedef expressions are output as normal functions.
      
      As we need to be clearer about the type with Sphinx 3.x,
      detect such cases.
      
      While here, fix a wrongly-indented block.
      
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      47bcacfd
    • Mauro Carvalho Chehab's avatar
      scripts: kernel-doc: reimplement -nofunction argument · eab795dd
      Mauro Carvalho Chehab authored
      
      Right now, the build system doesn't use -nofunction, as
      it is pretty much useless, because it doesn't consider
      the other output modes (extern, internal), working only
      with all.
      
      Also, it is limited to exclude functions.
      
      Re-implement it in order to allow excluding any symbols from
      the document output, no matter what mode is used.
      
      The parameter was also renamed to "-nosymbol", as it express
      better its meaning.
      
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      eab795dd
    • Mauro Carvalho Chehab's avatar
      scripts: kernel-doc: fix troubles with line counts · dbe8ba00
      Mauro Carvalho Chehab authored
      
      There's currently a bug with the way kernel-doc script
      counts line numbers that can be seen with:
      
      	$ ./scripts/kernel-doc -rst  -enable-lineno include/linux/math64.h >all && ./scripts/kernel-doc -rst -internal -enable-lineno include/linux/math64.h >int && diff -U0 int all
      
      	--- int	2020-09-28 12:58:08.927486808 +0200
      	+++ all	2020-09-28 12:58:08.905486845 +0200
      	@@ -1 +1 @@
      	-#define LINENO 27
      	+#define LINENO 26
      	@@ -3 +3 @@
      	-#define LINENO 16
      	+#define LINENO 15
      	@@ -9 +9 @@
      	-#define LINENO 17
      	+#define LINENO 16
      	...
      
      This is happening with perl version 5.30.3, but I'm not
      so sure if this is a perl bug, or if this is due to something
      else.
      
      In any case, fixing it is easy. Basically, when "-internal"
      parameter is used, the process_export_file() function opens the
      handle "IN". This makes the line number to be incremented, as the
      handler for the main open is also "IN".
      
      Fix the problem by using a different handler for the
      main open().
      
      While here, add a missing close for it.
      
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      dbe8ba00
    • Mauro Carvalho Chehab's avatar
      scripts: kernel-doc: use a less pedantic markup for funcs on Sphinx 3.x · e3ad05fe
      Mauro Carvalho Chehab authored
      Unfortunately, Sphinx 3.x parser for c functions is too pedantic:
      
      	https://github.com/sphinx-doc/sphinx/issues/8241
      
      
      
      While it could be relaxed with some configurations, there are
      several corner cases that it would make it hard to maintain,
      and will require teaching conf.py about several macros.
      
      So, let's instead use the :c:macro notation. This will
      produce an output that it is not as nice as currently, but it
      should still be acceptable, and will provide cross-references,
      removing thousands of warnings when building with newer
      versions of Sphinx.
      
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      e3ad05fe
    • Mauro Carvalho Chehab's avatar
      scripts: kernel-doc: make it more compatible with Sphinx 3.x · efa44475
      Mauro Carvalho Chehab authored
      
      With Sphinx 3.x, the ".. c:type:" tag was changed to accept either:
      
      	.. c:type:: typedef-like declaration
      	.. c:type:: name
      
      Using it for other types (including functions) don't work anymore.
      
      So, there are newer tags for macro, enum, struct, union, and others,
      which doesn't exist on older versions.
      
      Add a check for the Sphinx version and change the produced tags
      accordingly.
      
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      efa44475
    • Mauro Carvalho Chehab's avatar
      scripts: kernel-doc: add support for typedef enum · d38c8cfb
      Mauro Carvalho Chehab authored
      
      The PHY kernel-doc markup has gained support for documenting
      a typedef enum.
      
      However, right now the parser was not prepared for it.
      
      So, add support for parsing it.
      
      Fixes: 4069a572 ("net: phy: Document core PHY structures")
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      d38c8cfb
  5. Sep 16, 2020
  6. Sep 10, 2020
  7. Jul 31, 2020
    • Pierre-Louis Bossart's avatar
      scripts/kernel-doc: optionally treat warnings as errors · 2c12c810
      Pierre-Louis Bossart authored
      
      The kbuild bot recently added the W=1 option, which triggered
      documentation cleanups to squelch hundreds of kernel-doc warnings.
      
      To make sure new kernel contributions don't add regressions to
      kernel-doc descriptors, this patch suggests an option to treat
      warnings as errors in CI/automated tests.
      
      A -Werror command-line option is added to the kernel-doc script. When
      this option is set, the script will return the number of warnings
      found. The caller can then treat this positive return value as an
      error and stop the build.
      
      Using this command line option is however not straightforward when the
      kernel-doc script is called from other scripts. To align with typical
      kernel compilation or documentation generation, the Werror option is
      also set by checking the KCFLAGS environment variable, or if
      KDOC_WERROR is defined, as in the following examples:
      
      KCFLAGS="-Wall -Werror" make W=1 sound/
      KCFLAGS="-Wall -Werror" make W=1 drivers/soundwire/
      KDOC_WERROR=1 make htmldocs
      
      Note that in the last example the documentation build does not stop,
      only an additional log is provided.
      
      Credits to Randy Dunlap for suggesting the use of environment variables.
      
      Suggested-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Link: https://lore.kernel.org/r/20200728162040.92467-1-pierre-louis.bossart@linux.intel.com
      
      
      Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
      2c12c810
  8. Jun 26, 2020
  9. Jun 08, 2020
  10. Apr 20, 2020
  11. Apr 15, 2020
  12. Nov 07, 2019
  13. Oct 01, 2019
  14. Aug 12, 2019
  15. Aug 06, 2019
  16. Jun 26, 2019
    • Jonathan Corbet's avatar
      kernel-doc: Don't try to mark up function names · 344fdb28
      Jonathan Corbet authored
      
      We now have better automarkup in sphinx itself and, besides, this markup
      was incorrect and left :c:func: gunk in the processed docs.  Sort of
      discouraging that nobody ever noticed...:)
      
      As a first step toward the removal of impenetrable regex magic from
      kernel-doc it's a tiny one, but you have to start somewhere.
      
      Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
      344fdb28
  17. May 27, 2019
  18. Jan 16, 2019
    • Jonathan Corbet's avatar
      kernel-doc: suppress 'not described' warnings for embedded struct fields · be5cd20c
      Jonathan Corbet authored
      
      The ability to add kerneldoc comments for fields in embedded structures is
      useful, but it brought along a whole bunch of warnings for fields that
      could not be described before.  In many cases, there's little value in
      adding docs for these nested fields, and in cases like:
      
             	struct a {
                  struct b {
      	        int c;
      	    } d, e;
      	};
      
      "c" would have to be described twice (as d.c and e.c) to make the warnings
      go away.
      
      We can no doubt do something smarter, but simply suppressing the warnings
      for this case removes about 70 warnings from the docs build, freeing us to
      focus on the ones that matter more.  So make kerneldoc be silent about
      missing descriptions for any field containing a ".".
      
      Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
      be5cd20c
  19. Nov 25, 2018
  20. Nov 07, 2018
  21. Oct 18, 2018
    • Randy Dunlap's avatar
      kernel-doc: fix declaration type determination · cf419d54
      Randy Dunlap authored
      
      Make declaration type determination more robust.
      
      When scripts/kernel-doc is deciding if some kernel-doc notation
      contains an enum, a struct, a union, a typedef, or a function,
      it does a pattern match on the beginning of the string, looking
      for a match with one of "struct", "union", "enum", or "typedef",
      and otherwise defaults to a function declaration type.
      However, if a function or a function-like macro has a name that
      begins with "struct" (e.g., struct_size()), then kernel-doc
      incorrectly decides that this is a struct declaration.
      
      Fix this by looking for the declaration type keywords having an
      ending word boundary (\b), so that "struct_size" will not match
      a struct declaration.
      
      I compared lots of html before/after output from core-api, driver-api,
      and networking.  There were no differences in any of the files that
      I checked.
      
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Acked-by: default avatarJani Nikula <jani.nikula@intel.com>
      Tested-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
      cf419d54
  22. Aug 06, 2018
  23. Jul 23, 2018
  24. Mar 29, 2018
Loading