Mercurial > vim
annotate runtime/doc/doctags.c @ 33846:bc2505818986
runtime(html): Update syntax file (#13591)
Commit: https://github.com/vim/vim/commit/a9058440b7b9d7f5d0027c8cd44366e9200ca241
Author: dkearns <dougkearns@gmail.com>
Date: Wed Nov 29 06:41:41 2023 +1100
runtime(html): Update syntax file (https://github.com/vim/vim/issues/13591)
Add missing search element and update ARIA attribute list.
Add a very basic test file to check all elements are matched.
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 28 Nov 2023 20:45:07 +0100 |
parents | af4ffc4b2a26 |
children |
rev | line source |
---|---|
7 | 1 /* vim:set ts=4 sw=4: |
2 * | |
16808 | 3 * This program makes a tags file for help text. |
4 * | |
5 * Usage: doctags *.txt ... >tags | |
7 | 6 * |
7 * A tag in this context is an identifier between stars, e.g. *c_files* | |
8 */ | |
9 | |
10 #include <stdio.h> | |
11 #include <string.h> | |
12 #include <ctype.h> | |
13 #include <stdlib.h> | |
14 | |
15 #define LINELEN 200 | |
16 | |
17 int | |
7837
33ba2adb6065
commit https://github.com/vim/vim/commit/b638a7be952544ceb03052c25b84224577a6494b
Christian Brabandt <cb@256bit.org>
parents:
7
diff
changeset
|
18 main(int argc, char **argv) |
7 | 19 { |
20 char line[LINELEN]; | |
21 char *p1, *p2; | |
22 char *p; | |
23 FILE *fd; | |
29538
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
24 int len; |
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
25 int in_example; |
7 | 26 |
27 if (argc <= 1) | |
28 { | |
29 fprintf(stderr, "Usage: doctags docfile ... >tags\n"); | |
30 exit(1); | |
31 } | |
32 printf("help-tags\ttags\t1\n"); | |
33 while (--argc > 0) | |
34 { | |
35 ++argv; | |
36 fd = fopen(argv[0], "r"); | |
37 if (fd == NULL) | |
38 { | |
39 fprintf(stderr, "Unable to open %s for reading\n", argv[0]); | |
40 continue; | |
41 } | |
29538
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
42 in_example = 0; |
7 | 43 while (fgets(line, LINELEN, fd) != NULL) |
44 { | |
29538
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
45 if (in_example) |
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
46 { |
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
47 // skip over example; non-blank in first column ends example |
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
48 if (strchr(" \t\n\r", line[0]) != NULL) |
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
49 continue; |
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
50 in_example = 0; |
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
51 } |
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
52 p1 = strchr(line, '*'); // find first '*' |
7 | 53 while (p1 != NULL) |
54 { | |
29538
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
55 p2 = strchr(p1 + 1, '*'); // find second '*' |
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
56 if (p2 != NULL && p2 > p1 + 1) // skip "*" and "**" |
7 | 57 { |
58 for (p = p1 + 1; p < p2; ++p) | |
59 if (*p == ' ' || *p == '\t' || *p == '|') | |
60 break; | |
29538
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
61 // Only accept a *tag* when it consists of valid |
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
62 // characters, there is white space before it and is |
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
63 // followed by a white character or end-of-line. |
7 | 64 if (p == p2 |
65 && (p1 == line || p1[-1] == ' ' || p1[-1] == '\t') | |
66 && (strchr(" \t\n\r", p[1]) != NULL | |
67 || p[1] == '\0')) | |
68 { | |
69 *p2 = '\0'; | |
70 ++p1; | |
71 printf("%s\t%s\t/*", p1, argv[0]); | |
72 while (*p1) | |
73 { | |
29538
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
74 // insert backslash before '\\' and '/' |
7 | 75 if (*p1 == '\\' || *p1 == '/') |
76 putchar('\\'); | |
77 putchar(*p1); | |
78 ++p1; | |
79 } | |
80 printf("*\n"); | |
29538
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
81 p2 = strchr(p2 + 1, '*'); // find next '*' |
7 | 82 } |
83 } | |
84 p1 = p2; | |
85 } | |
29538
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
86 len = strlen(line); |
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
87 if ((len == 2 && strcmp(&line[len - 2], ">\n") == 0) |
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
88 || (len >= 3 && strcmp(&line[len - 3], " >\n") == 0)) |
af4ffc4b2a26
patch 9.0.0110: help tag generation picks up words in code examples
Bram Moolenaar <Bram@vim.org>
parents:
16808
diff
changeset
|
89 in_example = 1; |
7 | 90 } |
91 fclose(fd); | |
92 } | |
93 return 0; | |
94 } |