From 3592385668c3a32638a84557df999d7146cc3bb6 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 8 Apr 2025 18:09:08 +0800 Subject: scripts/kernel-doc.py: better handle empty sections While doing the conversion, we opted to skip empty sections (description, return), but this makes harder to see the differences between kernel-doc (Perl) and kernel-doc.py. Also, the logic doesn't always work properly. So, change the way this is done by adding an extra step to remove such sections, doing it only for Return and Description. Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Jonathan Corbet Link: https://lore.kernel.org/r/1b057092a48ba61d92a411f4f6d505b802913785.1744106241.git.mchehab+huawei@kernel.org --- scripts/kernel-doc.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'scripts/kernel-doc.py') diff --git a/scripts/kernel-doc.py b/scripts/kernel-doc.py index 8625209d6293..90808d538de7 100755 --- a/scripts/kernel-doc.py +++ b/scripts/kernel-doc.py @@ -317,6 +317,19 @@ class KernelDoc: name = self.entry.section contents = self.entry.contents + # TODO: we can prevent dumping empty sections here with: + # + # if self.entry.contents.strip("\n"): + # if start_new: + # self.entry.section = self.section_default + # self.entry.contents = "" + # + # return + # + # But, as we want to be producing the same output of the + # venerable kernel-doc Perl tool, let's just output everything, + # at least for now + if type_param.match(name): name = type_param.group(1) @@ -373,6 +386,19 @@ class KernelDoc: args["type"] = dtype + # TODO: use colletions.OrderedDict + + sections = args.get('sections', {}) + sectionlist = args.get('sectionlist', []) + + # Drop empty sections + # TODO: improve it to emit warnings + for section in [ "Description", "Return" ]: + if section in sectionlist: + if not sections[section].rstrip(): + del sections[section] + sectionlist.remove(section) + self.entries.append((name, args)) self.config.log.debug("Output: %s:%s = %s", dtype, name, pformat(args)) @@ -476,7 +502,7 @@ class KernelDoc: # to ignore "[blah" in a parameter string. self.entry.parameterlist.append(param) - org_arg = Re(r'\s\s+').sub(' ', org_arg, count=1) + org_arg = Re(r'\s\s+').sub(' ', org_arg) self.entry.parametertypes[param] = org_arg def save_struct_actual(self, actual): @@ -1384,8 +1410,7 @@ class KernelDoc: return if doc_end.search(line): - if self.entry.contents.strip("\n"): - self.dump_section() + self.dump_section() # Look for doc_com + + doc_end: r = Re(r'\s*\*\s*[a-zA-Z_0-9:\.]+\*/') -- cgit v1.2.3 ;follow=1'>export-to-postgresql.py (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2018-11-06drm/amd/display: Fix misleading buffer informationShaokun Zhang1-2/+2
2018-11-06Revert "drm/amd/display: set backlight level limit to 1"Alex Deucher1-7/+0
2018-11-06drm/amd: Update atom_smu_info_v3_3 structureLeo Li1-2/+5
2018-11-05uapi: fix more linux/kfd_ioctl.h userspace compilation errorsDmitry V. Levin1-5/+5
2018-11-05uapi: fix linux/kfd_ioctl.h userspace compilation errorsDmitry V. Levin1-4/+4
2018-11-04Linux 4.20-rc1v4.20-rc1Linus Torvalds1-2/+2
2018-11-04sched/topology: Fix off by one bugPeter Zijlstra1-1/+1
2018-11-03memory_hotplug: cond_resched in __remove_pagesMichal Hocko1-0/+1
2018-11-03bfs: add sanity check at bfs_fill_super()Tetsuo Handa1-3/+6
2018-11-03kernel/sysctl.c: remove duplicated includeMichael Schupikov1-1/+0
2018-11-03kernel/kexec_file.c: remove some duplicated includeszhong jiang1-2/+0
2018-11-03mm, thp: consolidate THP gfp handling into alloc_hugepage_direct_gfpmaskMichal Hocko5-77/+40
2018-11-03ocfs2: fix clusters leak in ocfs2_defrag_extent()Larry Chen1-0/+17
2018-11-03ocfs2: dlmglue: clean up timestamp handlingArnd Bergmann1-17/+9
2018-11-03ocfs2: don't put and assigning null to bh allocated outsideChangwei Ge1-18/+59
2018-11-03ocfs2: fix a misuse a of brelse after failing ocfs2_check_dir_entryChangwei Ge1-2/+1
2018-11-03ocfs2: don't use iocb when EIOCBQUEUED returnsChangwei Ge1-2/+2
2018-11-03ocfs2: without quota support, avoid calling quota recoveryGuozhonghua1-17/+34
2018-11-03ocfs2: remove ocfs2_is_o2cb_active()Gang He3-10/+1
2018-11-03mm: thp: relax __GFP_THISNODE for MADV_HUGEPAGE mappingsAndrea Arcangeli1-2/+30
2018-11-03include/linux/notifier.h: SRCU: fix ctagsSam Protsenko1-2/+1
2018-11-03mm: handle no memcg case in memcg_kmem_charge() properlyRoman Gushchin1-1/+1
2018-11-02ARM: dts: stm32: update HASH1 dmas property on stm32mp157cAlexandre Torgue1-1/+1
2018-11-02ARM: orion: avoid VLA in orion_mpp_confArnd Bergmann1-1/+6
2018-11-02iov_iter: Fix 9p virtio breakageMarc Zyngier1-1/+1
2018-11-02cifs: fix signed/unsigned mismatch on aio_read patchSteve French1-6/+11
2018-11-02cifs: don't dereference smb_file_target before null checkColin Ian King1-2/+5
2018-11-02CIFS: Add direct I/O functions to file_operationsLong Li1-6/+4
2018-11-02CIFS: Add support for direct I/O writeLong Li2-41/+164
2018-11-02CIFS: Add support for direct I/O readLong Li3-39/+192
2018-11-02smb3: missing defines and structs for reparse point handlingSteve French2-0/+38
2018-11-02smb3: allow more detailed protocol info on open files for debuggingSteve French4-0/+65
2018-11-02smb3: on kerberos mount if server doesn't specify auth type use krb5Steve French1-2/+4
2018-11-02smb3: add trace point for tree connectionSteve French2-1/+44
2018-11-02cifs: fix spelling mistake, EACCESS -> EACCESColin Ian King2-3/+3
2018-11-02cifs: fix return value for cifs_listxattrRonnie Sahlberg1-5/+6