Skip to content

Commit d9f079a

Browse files
committed
CodingGuidelines: document the API in *.h files
It makes it harder to let the API description and the reality drift apart if the doc is kept close to the implementation or the header of the API. We have been slowly migrating API docs out of the Documentation/technical/api-* to *.h files, and the development community generally considers that how inline docs in strbuf.h is done the best current practice. We recommend documenting in the header over documenting near the implementation to encourage people to write the docs that are readable without peeking at the implemention. Helped-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1d4361b commit d9f079a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Documentation/CodingGuidelines

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,10 @@ For C programs:
358358
string_list for sorted string lists, a hash map (mapping struct
359359
objects) named "struct decorate", amongst other things.
360360

361-
- When you come up with an API, document it.
361+
- When you come up with an API, document its functions and structures
362+
in the header file that exposes the API to its callers. Use what is
363+
in "strbuf.h" as a model for the appropriate tone and level of
364+
detail.
362365

363366
- The first #include in C files, except in platform specific compat/
364367
implementations, must be either "git-compat-util.h", "cache.h" or

0 commit comments

Comments
 (0)