Skip to content

Commit

Permalink
KernelDoc: new parser
Browse files Browse the repository at this point in the history
This one is disabled by default.
Give --languages=+KernelDoc for enabling.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed Jan 4, 2023
1 parent 3156388 commit dfdadb1
Show file tree
Hide file tree
Showing 17 changed files with 539 additions and 30 deletions.
61 changes: 31 additions & 30 deletions Tmain/list-subparsers-all.d/stdout-expected.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
#NAME BASEPARSER DIRECTIONS
AnsiblePlaybook Yaml base <> sub {bidirectional}
Ant XML base <> sub {bidirectional}
Autoconf M4 base <> sub {bidirectional}
Automake Make base <= sub {dedicated}
Bats Sh base <= sub {dedicated}
DBusIntrospect XML base <> sub {bidirectional}
FunctionParameters Perl base <> sub {bidirectional}
GemSpec Ruby base <= sub {dedicated}
Glade XML base <> sub {bidirectional}
IPythonCell Python base => sub {shared}
ITcl Tcl base <> sub {bidirectional}
Maven2 XML base <> sub {bidirectional}
Moose Perl base <> sub {bidirectional}
OpenAPI Yaml base <> sub {bidirectional}
PlistXML XML base <> sub {bidirectional}
PythonLoggingConfig Iniconf base <> sub {bidirectional}
QtMoc C++ base <> sub {bidirectional}
R6Class R base <> sub {bidirectional}
RMarkdown Markdown base <= sub {dedicated}
RSpec Ruby base => sub {shared}
Rake Ruby base <= sub {dedicated}
RelaxNG XML base <> sub {bidirectional}
S4Class R base <> sub {bidirectional}
SVG XML base <> sub {bidirectional}
SystemdUnit Iniconf base <= sub {dedicated}
TclOO Tcl base <> sub {bidirectional}
TeXBeamer Tex base <> sub {bidirectional}
XSLT XML base <> sub {bidirectional}
YumRepo Iniconf base <= sub {dedicated}
#NAME BASEPARSER DIRECTIONS
AnsiblePlaybook Yaml base <> sub {bidirectional}
Ant XML base <> sub {bidirectional}
Autoconf M4 base <> sub {bidirectional}
Automake Make base <= sub {dedicated}
Bats Sh base <= sub {dedicated}
DBusIntrospect XML base <> sub {bidirectional}
FunctionParameters Perl base <> sub {bidirectional}
GemSpec Ruby base <= sub {dedicated}
Glade XML base <> sub {bidirectional}
IPythonCell Python base => sub {shared}
ITcl Tcl base <> sub {bidirectional}
KernelDoc CPreProcessor base => sub {shared}
Maven2 XML base <> sub {bidirectional}
Moose Perl base <> sub {bidirectional}
OpenAPI Yaml base <> sub {bidirectional}
PlistXML XML base <> sub {bidirectional}
PythonLoggingConfig Iniconf base <> sub {bidirectional}
QtMoc C++ base <> sub {bidirectional}
R6Class R base <> sub {bidirectional}
RMarkdown Markdown base <= sub {dedicated}
RSpec Ruby base => sub {shared}
Rake Ruby base <= sub {dedicated}
RelaxNG XML base <> sub {bidirectional}
S4Class R base <> sub {bidirectional}
SVG XML base <> sub {bidirectional}
SystemdUnit Iniconf base <= sub {dedicated}
TclOO Tcl base <> sub {bidirectional}
TeXBeamer Tex base <> sub {bidirectional}
XSLT XML base <> sub {bidirectional}
YumRepo Iniconf base <= sub {dedicated}
7 changes: 7 additions & 0 deletions Units/parser-kerneldoc.r/dots-in-members.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--sort=no
--languages=+KernelDoc
--fields=+Kl
--extras=+g
--kinds-KernelDoc=*
--kinds-C=
--kinds-CPreProcessor=
12 changes: 12 additions & 0 deletions Units/parser-kerneldoc.r/dots-in-members.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
nested_foobar input.c /^ * struct nested_foobar - a struct with nested unions and structs$/;" struct language:KernelDoc
memb1 input.c /^ * @memb1: first member of anonymous union\/anonymous struct$/;" member language:KernelDoc struct:nested_foobar
memb2 input.c /^ * @memb2: second member of anonymous union\/anonymous struct$/;" member language:KernelDoc struct:nested_foobar
memb3 input.c /^ * @memb3: third member of anonymous union\/anonymous struct$/;" member language:KernelDoc struct:nested_foobar
memb4 input.c /^ * @memb4: fourth member of anonymous union\/anonymous struct$/;" member language:KernelDoc struct:nested_foobar
bar input.c /^ * @bar: non-anonymous union$/;" member language:KernelDoc struct:nested_foobar
bar.st1 input.c /^ * @bar.st1: struct st1 inside @bar$/;" member language:KernelDoc struct:nested_foobar
bar.st2 input.c /^ * @bar.st2: struct st2 inside @bar$/;" member language:KernelDoc struct:nested_foobar
bar.st1.memb1 input.c /^ * @bar.st1.memb1: first member of struct st1 on union bar$/;" member language:KernelDoc struct:nested_foobar
bar.st1.memb2 input.c /^ * @bar.st1.memb2: second member of struct st1 on union bar$/;" member language:KernelDoc struct:nested_foobar
bar.st2.memb1 input.c /^ * @bar.st2.memb1: first member of struct st2 on union bar$/;" member language:KernelDoc struct:nested_foobar
bar.st2.memb2 input.c /^ * @bar.st2.memb2: second member of struct st2 on union bar$/;" member language:KernelDoc struct:nested_foobar
38 changes: 38 additions & 0 deletions Units/parser-kerneldoc.r/dots-in-members.d/input.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* Taken from linux/Documentation/doc-guide/kernel-doc.rst */
/**
* struct nested_foobar - a struct with nested unions and structs
* @memb1: first member of anonymous union/anonymous struct
* @memb2: second member of anonymous union/anonymous struct
* @memb3: third member of anonymous union/anonymous struct
* @memb4: fourth member of anonymous union/anonymous struct
* @bar: non-anonymous union
* @bar.st1: struct st1 inside @bar
* @bar.st2: struct st2 inside @bar
* @bar.st1.memb1: first member of struct st1 on union bar
* @bar.st1.memb2: second member of struct st1 on union bar
* @bar.st2.memb1: first member of struct st2 on union bar
* @bar.st2.memb2: second member of struct st2 on union bar
*/
struct nested_foobar {
/* Anonymous union/struct*/
union {
struct {
int memb1;
int memb2;
};
struct {
void *memb3;
int memb4;
};
};
union {
struct {
int memb1;
int memb2;
} st1;
struct {
void *memb1;
int memb2;
} st2;
} bar;
};
7 changes: 7 additions & 0 deletions Units/parser-kerneldoc.r/inline.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--sort=no
--languages=+KernelDoc
--fields=+Kl
--extras=+g
--kinds-KernelDoc=*
--kinds-C=
--kinds-CPreProcessor=
7 changes: 7 additions & 0 deletions Units/parser-kerneldoc.r/inline.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
foo input.c /^ * struct foo - Brief description.$/;" struct language:KernelDoc
foo input.c /^ * @foo: The Foo member.$/;" member language:KernelDoc struct:foo
@bar input.c /^ * @bar: The Bar member.$/;" unknown language:GtkDoc
@baz input.c /^ * @baz: The Baz member.$/;" unknown language:GtkDoc
@foobar input.c /^ \/** @foobar: Single line description. *\/$/;" unknown language:GtkDoc
@bar2 input.c /^ \/** @bar2: Description for struct @bar2 inside @foo *\/$/;" unknown language:GtkDoc
@bar2.barbar input.c /^ * @bar2.barbar: Description for @barbar inside @foo.bar2$/;" unknown language:GtkDoc
29 changes: 29 additions & 0 deletions Units/parser-kerneldoc.r/inline.d/input.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* Taken from linux/Documentation/doc-guide/kernel-doc.rst */
/**
* struct foo - Brief description.
* @foo: The Foo member.
*/
struct foo {
int foo;
/**
* @bar: The Bar member.
*/
int bar;
/**
* @baz: The Baz member.
*
* Here, the member description may contain several paragraphs.
*/
int baz;
union {
/** @foobar: Single line description. */
int foobar;
};
/** @bar2: Description for struct @bar2 inside @foo */
struct {
/**
* @bar2.barbar: Description for @barbar inside @foo.bar2
*/
int barbar;
} bar2;
};
7 changes: 7 additions & 0 deletions Units/parser-kerneldoc.r/simple.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--sort=no
--languages=+KernelDoc
--fields=+Kl
--extras=+g
--kinds-KernelDoc=*
--kinds-C=
--kinds-CPreProcessor=
20 changes: 20 additions & 0 deletions Units/parser-kerneldoc.r/simple.d/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cpuhp_invoke_callback input.c /^ * cpuhp_invoke_callback - Invoke the callbacks for a given state$/;" unknown language:KernelDoc
cpu input.c /^ * @cpu: The cpu for which the callback should be invoked$/;" parameter language:KernelDoc unknown:cpuhp_invoke_callback
state input.c /^ * @state: The state to do callbacks for$/;" parameter language:KernelDoc unknown:cpuhp_invoke_callback
bringup input.c /^ * @bringup: True if the bringup callback should be invoked$/;" parameter language:KernelDoc unknown:cpuhp_invoke_callback
node input.c /^ * @node: For multi-instance, do a single entry callback for install\/remove$/;" parameter language:KernelDoc unknown:cpuhp_invoke_callback
lastp input.c /^ * @lastp: For multi-instance rollback, remember how far we got$/;" parameter language:KernelDoc unknown:cpuhp_invoke_callback
ACPI_DEVICE_CLASS input.c /^ * ACPI_DEVICE_CLASS - macro used to describe an ACPI device with$/;" unknown language:KernelDoc
_cls input.c /^ * @_cls : the class, subclass, prog-if triple for this device$/;" parameter language:KernelDoc unknown:ACPI_DEVICE_CLASS
_msk input.c /^ * @_msk : the class mask for this device$/;" parameter language:KernelDoc unknown:ACPI_DEVICE_CLASS
acpi_dma_spec input.c /^ * struct acpi_dma_spec - slave device DMA resources$/;" struct language:KernelDoc
chan_id input.c /^ * @chan_id: channel unique id$/;" member language:KernelDoc struct:acpi_dma_spec
slave_id input.c /^ * @slave_id: request line unique id$/;" member language:KernelDoc struct:acpi_dma_spec
dev input.c /^ * @dev: struct device of the DMA controller to be used in the filter$/;" member language:KernelDoc struct:acpi_dma_spec
dma_cookie_t input.c /^ * typedef dma_cookie_t - an opaque DMA cookie$/;" typedef language:KernelDoc
coresight_dev_subtype input.c /^ * union coresight_dev_subtype - further characterisation of a type$/;" union language:KernelDoc
sink_subtype input.c /^ * @sink_subtype: type of sink this component is, as defined$/;" member language:KernelDoc union:coresight_dev_subtype
link_subtype input.c /^ * @link_subtype: type of link this component is, as defined$/;" member language:KernelDoc union:coresight_dev_subtype
source_subtype input.c /^ * @source_subtype: type of source this component is, as defined$/;" member language:KernelDoc union:coresight_dev_subtype
helper_subtype input.c /^ * @helper_subtype: type of helper this component is, as defined$/;" member language:KernelDoc union:coresight_dev_subtype
ect_subtype input.c /^ * @ect_subtype: type of cross trigger this component is, as$/;" member language:KernelDoc union:coresight_dev_subtype
81 changes: 81 additions & 0 deletions Units/parser-kerneldoc.r/simple.d/input.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/* Taken from linux/kernel/cpu.c */

/**
* cpuhp_invoke_callback - Invoke the callbacks for a given state
* @cpu: The cpu for which the callback should be invoked
* @state: The state to do callbacks for
* @bringup: True if the bringup callback should be invoked
* @node: For multi-instance, do a single entry callback for install/remove
* @lastp: For multi-instance rollback, remember how far we got
*
* Called from cpu hotplug and from the state register machinery.
*
* Return: %0 on success or a negative errno code
*/
static int cpuhp_invoke_callback(unsigned int cpu, enum cpuhp_state state,
bool bringup, struct hlist_node *node,
struct hlist_node **lastp)
{
return 0;
}

/* Taken from linux/include/linux/acpi.h */
/**
* ACPI_DEVICE_CLASS - macro used to describe an ACPI device with
* the PCI-defined class-code information
*
* @_cls : the class, subclass, prog-if triple for this device
* @_msk : the class mask for this device
*
* This macro is used to create a struct acpi_device_id that matches a
* specific PCI class. The .id and .driver_data fields will be left
* initialized with the default value.
*/
#define ACPI_DEVICE_CLASS(_cls, _msk) .cls = (_cls), .cls_msk = (_msk),

/* Taken from linux/include/linux/acpi_dma.h */
/**
* struct acpi_dma_spec - slave device DMA resources
* @chan_id: channel unique id
* @slave_id: request line unique id
* @dev: struct device of the DMA controller to be used in the filter
* function
*/
struct acpi_dma_spec {
int chan_id;
int slave_id;
struct device *dev;
};

/* Taken from linux/include/linux/dmaengine.h */
/**
* typedef dma_cookie_t - an opaque DMA cookie
*
* if dma_cookie_t is >0 it's a DMA request cookie, <0 it's an error code
*/
typedef s32 dma_cookie_t;

/* Taken from linux/include/linux/coresight.h */
/**
* union coresight_dev_subtype - further characterisation of a type
* @sink_subtype: type of sink this component is, as defined
* by @coresight_dev_subtype_sink.
* @link_subtype: type of link this component is, as defined
* by @coresight_dev_subtype_link.
* @source_subtype: type of source this component is, as defined
* by @coresight_dev_subtype_source.
* @helper_subtype: type of helper this component is, as defined
* by @coresight_dev_subtype_helper.
* @ect_subtype: type of cross trigger this component is, as
* defined by @coresight_dev_subtype_ect
*/
union coresight_dev_subtype {
/* We have some devices which acts as LINK and SINK */
struct {
enum coresight_dev_subtype_sink sink_subtype;
enum coresight_dev_subtype_link link_subtype;
};
enum coresight_dev_subtype_source source_subtype;
enum coresight_dev_subtype_helper helper_subtype;
enum coresight_dev_subtype_ect ect_subtype;
};
7 changes: 7 additions & 0 deletions Units/parser-kerneldoc.r/typedef-with-prototype.d/args.ctags
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--sort=no
--languages=+KernelDoc
--fields=+Kl
--extras=+g
--kinds-KernelDoc=*
--kinds-C=
--kinds-CPreProcessor=
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type_name input.c /^ * typedef type_name - Brief description.$/;" typedef language:KernelDoc
arg1 input.c /^ * @arg1: description of arg1$/;" parameter language:KernelDoc typedef:type_name
arg2 input.c /^ * @arg2: description of arg2$/;" parameter language:KernelDoc typedef:type_name
12 changes: 12 additions & 0 deletions Units/parser-kerneldoc.r/typedef-with-prototype.d/input.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* Taken from linux/Documentation/doc-guide/kernel-doc.rst */
/**
* typedef type_name - Brief description.
* @arg1: description of arg1
* @arg2: description of arg2
*
* Description of the type.
*
* Context: Locking context.
* Return: Meaning of the return value.
*/
typedef void (*type_name)(struct v4l2_ctrl *arg1, void *arg2);
1 change: 1 addition & 0 deletions docs/news.rst
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ The following parsers have been added:
* JSON
* Julia
* Kconfig *optlib*
* KernelDoc *CPreProcessor based subparser"
* Kotlin *peg/packcc*
* GNU linker script(LdScript)
* LEX *optlib*
Expand Down
1 change: 1 addition & 0 deletions main/parsers_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
JsonParser, \
JuliaParser, \
KconfigParser, \
KernelDocParser, \
LdScriptParser, \
LEXParser, \
LispParser, \
Expand Down
Loading

0 comments on commit dfdadb1

Please sign in to comment.