Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs: kdoc: drop "sectionlist"

Python dicts (as of 3.7) are guaranteed to remember the insertion order of
items, so we do not need a separate list for that purpose. Drop the
per-entry sectionlist variable and just rely on native dict ordering.

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

+7 -24
+6 -12
scripts/lib/kdoc/kdoc_output.py
··· 339 339 tends to duplicate a header already in the template file. 340 340 """ 341 341 342 - sectionlist = args.get('sectionlist', []) 343 342 sections = args.get('sections', {}) 344 343 section_start_lines = args.get('section_start_lines', {}) 345 344 346 - for section in sectionlist: 345 + for section in sections: 347 346 # Skip sections that are in the nosymbol_table 348 347 if section in self.nosymbol: 349 348 continue ··· 635 636 self.data += line + "\n" 636 637 637 638 def out_doc(self, fname, name, args): 638 - sectionlist = args.get('sectionlist', []) 639 639 sections = args.get('sections', {}) 640 640 641 641 if not self.check_doc(name, args): ··· 642 644 643 645 self.data += f'.TH "{self.modulename}" 9 "{self.modulename}" "{self.man_date}" "API Manual" LINUX' + "\n" 644 646 645 - for section in sectionlist: 647 + for section in sections: 646 648 self.data += f'.SH "{section}"' + "\n" 647 649 self.output_highlight(sections.get(section)) 648 650 ··· 651 653 652 654 parameterlist = args.get('parameterlist', []) 653 655 parameterdescs = args.get('parameterdescs', {}) 654 - sectionlist = args.get('sectionlist', []) 655 656 sections = args.get('sections', {}) 656 657 657 658 self.data += f'.TH "{args["function"]}" 9 "{args["function"]}" "{self.man_date}" "Kernel Hacker\'s Manual" LINUX' + "\n" ··· 692 695 self.data += f'.IP "{parameter}" 12' + "\n" 693 696 self.output_highlight(parameterdescs.get(parameter_name, "")) 694 697 695 - for section in sectionlist: 698 + for section in sections: 696 699 self.data += f'.SH "{section.upper()}"' + "\n" 697 700 self.output_highlight(sections[section]) 698 701 ··· 700 703 701 704 name = args.get('enum', '') 702 705 parameterlist = args.get('parameterlist', []) 703 - sectionlist = args.get('sectionlist', []) 704 706 sections = args.get('sections', {}) 705 707 706 708 self.data += f'.TH "{self.modulename}" 9 "enum {args["enum"]}" "{self.man_date}" "API Manual" LINUX' + "\n" ··· 727 731 self.data += f'.IP "{parameter}" 12' + "\n" 728 732 self.output_highlight(args['parameterdescs'].get(parameter_name, "")) 729 733 730 - for section in sectionlist: 734 + for section in sections: 731 735 self.data += f'.SH "{section}"' + "\n" 732 736 self.output_highlight(sections[section]) 733 737 ··· 735 739 module = self.modulename 736 740 typedef = args.get('typedef') 737 741 purpose = args.get('purpose') 738 - sectionlist = args.get('sectionlist', []) 739 742 sections = args.get('sections', {}) 740 743 741 744 self.data += f'.TH "{module}" 9 "{typedef}" "{self.man_date}" "API Manual" LINUX' + "\n" ··· 742 747 self.data += ".SH NAME\n" 743 748 self.data += f"typedef {typedef} \\- {purpose}\n" 744 749 745 - for section in sectionlist: 750 + for section in sections: 746 751 self.data += f'.SH "{section}"' + "\n" 747 752 self.output_highlight(sections.get(section)) 748 753 ··· 752 757 struct_name = args.get('struct') 753 758 purpose = args.get('purpose') 754 759 definition = args.get('definition') 755 - sectionlist = args.get('sectionlist', []) 756 760 parameterlist = args.get('parameterlist', []) 757 761 sections = args.get('sections', {}) 758 762 parameterdescs = args.get('parameterdescs', {}) ··· 782 788 self.data += f'.IP "{parameter}" 12' + "\n" 783 789 self.output_highlight(parameterdescs.get(parameter_name)) 784 790 785 - for section in sectionlist: 791 + for section in sections: 786 792 self.data += f'.SH "{section}"' + "\n" 787 793 self.output_highlight(sections.get(section))
+1 -12
scripts/lib/kdoc/kdoc_parser.py
··· 127 127 self.parameterdesc_start_lines = {} 128 128 129 129 self.section_start_lines = {} 130 - self.sectionlist = [] 131 130 self.sections = {} 132 131 133 132 self.anon_struct_union = False ··· 201 202 self.sections[name] += '\n' + contents 202 203 else: 203 204 self.sections[name] = contents 204 - self.sectionlist.append(name) 205 205 self.section_start_lines[name] = self.new_start_line 206 206 self.new_start_line = 0 207 207 ··· 273 275 item.warnings = self.entry.warnings 274 276 275 277 sections = item.get('sections', {}) 276 - sectionlist = item.get('sectionlist', []) 277 278 278 279 # Drop empty sections 279 280 # TODO: improve empty sections logic to emit warnings 280 281 for section in ["Description", "Return"]: 281 - if section in sectionlist and not sections[section].rstrip(): 282 + if section in sections and not sections[section].rstrip(): 282 283 del sections[section] 283 - sectionlist.remove(section) 284 284 285 285 self.entries.append(item) 286 286 ··· 824 828 parameterdescs=self.entry.parameterdescs, 825 829 parametertypes=self.entry.parametertypes, 826 830 parameterdesc_start_lines=self.entry.parameterdesc_start_lines, 827 - sectionlist=self.entry.sectionlist, 828 831 sections=self.entry.sections, 829 832 section_start_lines=self.entry.section_start_lines, 830 833 purpose=self.entry.declaration_purpose) ··· 908 913 parameterlist=self.entry.parameterlist, 909 914 parameterdescs=self.entry.parameterdescs, 910 915 parameterdesc_start_lines=self.entry.parameterdesc_start_lines, 911 - sectionlist=self.entry.sectionlist, 912 916 sections=self.entry.sections, 913 917 section_start_lines=self.entry.section_start_lines, 914 918 purpose=self.entry.declaration_purpose) ··· 1079 1085 parameterdescs=self.entry.parameterdescs, 1080 1086 parametertypes=self.entry.parametertypes, 1081 1087 parameterdesc_start_lines=self.entry.parameterdesc_start_lines, 1082 - sectionlist=self.entry.sectionlist, 1083 1088 sections=self.entry.sections, 1084 1089 section_start_lines=self.entry.section_start_lines, 1085 1090 purpose=self.entry.declaration_purpose, ··· 1092 1099 parameterdescs=self.entry.parameterdescs, 1093 1100 parametertypes=self.entry.parametertypes, 1094 1101 parameterdesc_start_lines=self.entry.parameterdesc_start_lines, 1095 - sectionlist=self.entry.sectionlist, 1096 1102 sections=self.entry.sections, 1097 1103 section_start_lines=self.entry.section_start_lines, 1098 1104 purpose=self.entry.declaration_purpose, ··· 1137 1145 parameterdescs=self.entry.parameterdescs, 1138 1146 parametertypes=self.entry.parametertypes, 1139 1147 parameterdesc_start_lines=self.entry.parameterdesc_start_lines, 1140 - sectionlist=self.entry.sectionlist, 1141 1148 sections=self.entry.sections, 1142 1149 section_start_lines=self.entry.section_start_lines, 1143 1150 purpose=self.entry.declaration_purpose) ··· 1159 1168 1160 1169 self.output_declaration('typedef', declaration_name, 1161 1170 typedef=declaration_name, 1162 - sectionlist=self.entry.sectionlist, 1163 1171 sections=self.entry.sections, 1164 1172 section_start_lines=self.entry.section_start_lines, 1165 1173 purpose=self.entry.declaration_purpose) ··· 1643 1653 if doc_end.search(line): 1644 1654 self.dump_section() 1645 1655 self.output_declaration("doc", self.entry.identifier, 1646 - sectionlist=self.entry.sectionlist, 1647 1656 sections=self.entry.sections, 1648 1657 section_start_lines=self.entry.section_start_lines) 1649 1658 self.reset_state(ln)