• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..23-Dec-2019-

Doxyfile.templateH A D23-Dec-201974.6 KiB1,7931,299

README.mdH A D23-Dec-20195.9 KiB155116

doxify.shH A D23-Dec-20191.3 KiB4122

fixcomments.plH A D23-Dec-201925.7 KiB692463

is_fypp.pyH A D23-Dec-2019360 159

remove_double_ampersands.plH A D23-Dec-20192 KiB8231

remove_extra_comments.plH A D23-Dec-20191.7 KiB7728

README.md

1## DOXYGEN
2
3This file describes the scripts used to add missing comments and parse existing comments
4for subroutines and functions in CP2K. The objective of the scripts is to ensure that
5all subroutines and functions in CP2K have a standard DOXYGEN comment block and to flag
6any missing comments such that the CP2K developers can add/update these when time is
7available.
8
9The driver script `doxyify.sh` will process CP2K source code (`*.F` files)
10processing one file at a time. The following steps are carried out for each `*.F` file:
11
121. Run `remove_double_ampersands.pl` - removes any any double ampersand characters
132. Run `fixcomments.pl` - does the addition of missing comments or updating of existing comments
143. Run `remove_extra_comments.pl` - removes any extra comment lines which arise from application
15of `fixcomments.pl`
164. Finally, overwrite the original `*.F` file with the updated version
17
18To run the script, you should execute it with the name of the source file you want to
19process:
20
21```console
22./doxyify.sh full_path_to_cp2k_src/myfile.F
23```
24
25or with a list of files, e.g.
26```console
27./doxyify.sh full_path_to_cp2k_src/myfile.F full_path_to_cp2k_src/myfile2.F full_path_to_cp2k_src/myfile2.F
28```
29
30In debug mode, the script will produce a lot of output if the whole source tree is processed so you may
31wish to redirect the stdout to file, e.g.
32
33```console
34./doxyify.sh > comments.txt
35```
36
37### `remove_double_ampersands.pl`
38
39Removes any double ampersand characters that occur at the end of one line and the start of
40the next line, e.g:
41
42```fortran
43SUBROUTINE fred(a,b, &
44   & c,d)
45```
46
47becomes
48
49```fortran
50SUBROUTINE fred(a,b, &
51     c,d)
52```
53
54This is performed throughout the source code and is necessary as the ampersand is used
55by `fixcomments.pl` to determine whether a subroutine/function definition extends across
56multiple lines.
57
58
59### `fixcomments.pl`
60The script adds in missing comments and parses existing comments checking whether any data
61is missing. For procedures with no existing comments, e.g. a subroutine with 3 arguments `a`, `b`
62and `c:
63
64```fortran
65SUBROUTINE fred (a,b,c)
66```
67
68will be updated to (the ... are to indicate comments are required)
69```fortran
70! *****************************************************************************
71!> \brief ...
72!> \param a ...
73!> \param b ...
74!> \param c ...
75! *****************************************************************************
76SUBROUTINE fred (a,b,c)
77```
78
79The scripts works as follows:
80
81- We read through the source file until we see a comment block e.g. something beginning
82with !>
83
84- We then loop over the comment block looking for entries for \brief, \param, \date,
85\par, \version and \note and \author. If any of these items exist we store the details
86in separate variables. We also keep a copy of the entire comment block in the oldheader
87variable as we need to print the comment block out unchanged for MODULE and TYPE. When
88parsing the header we ensure that we don't throw any text away.
89
90- Once the comment block has been read in we continue reading in the code line by line.
91If we don't encounter any procedures then the output file will be identical to the
92input file.
93
94- However, if we encounter a procedure we then read in the line(s) containing the
95definition, e.g.
96
97```fortran
98SUBROUTINE fred(a,b,c)
99```
100
101to an array called `@string`. We do this by splitting over space, comma, brackets etc. We
102also take into account of the fact a subroutine / function definition can extend over multiple
103lines via the ampersand (`&`) character and ampersand variable. The `@string` array then contains
104the type of procedure, its name and the arguments, e.g. for the example above `@string` would
105contain 5 elements: `SUBROUTINE`, `fred`, `a`, `b`, `c`.
106
107- Once we know the name and arguments of the procedure we loop over the arguments checking
108to see whether the comment block contained a match. If it is does we use the existing text,
109if no match is found then the standard text detailed above is output. We also check whether
110any text exists for the `\brief` entry and re-use this if available, otherwise the `\brief ...`
111text is added as detailed above. The script can also handle `\date`, `\par`, `\author`, `\note` and
112`\version` entries if these should be required in future. At present these entries are copied
113across unchanged if they exist and otherwise they are not added in.
114
115- Finally anything else that was found in the comment block is output and suitably annotated.
116For example unmatched procedure arguments are flagged up, lines which begin with `!>`, `!`, or
117`!> \something_or_other` are also annotated.
118
119- The annotations used for marking up the comment block are as follows:
120
121  - `...` Added to `\brief` and `\param` only if no existing information is available. Other
122commonly occurring entries such as `\par`, `\author`, `\version`, `\note` and `\date` if they exist
123are passed through unchanged.
124
125  - `UNMATCHED_PROCEDURE_ARGUMENT` - gets appended on to any procedure arguments in the comment block
126that don't match those in the procedure definition.
127
128  - `UNKNOWN_DOXYGEN_COMMENT` - for parts of the comment block which look like a standard Doxygen
129block (e.g. lines that look like: `!> \something or other`) but not part of the standard
130header above.
131
132  - `UNKNOWN_COMMENT` - lines that begin `!>` or `!` inside the comment block. These get placed into
133a `!> \note with UNKNOWN_COMMENT` added at the start of the line.
134
135The script also includes checks to ensure that the annotations are not added to a line
136multiple times.
137
138### `remove_extra_comments.pl`
139Post-processing script to remove any double lines which begin `! ******`
140e.g.
141
142```fortran
143! *****************************************************************************
144! *****************************************************************************
145```
146
147gets changed to
148
149```fortran
150! *****************************************************************************
151```
152
153This is necessary because occasionally a procedure may be missing the start
154or end `! ****` line or may have a duplicate one.
155