Sample Header Ad - 728x90

How to extract function comment using sed?

3 votes
1 answer
324 views
I want to implement a simple utility that would take a C source file and a name of a function, struct, enum or whatever and output the comment directly above the element if present. Ie. /* This is a doc comment * I want this comment extracted */ void function_foo(){ } Usage: utility file.c function_foo Output: This is a doc comment I want this comment extracted The use case for this is that I want to use org-babel in emacs to tangle in documentation for functions right out of source files. Maybe there is a doxygen tool or clang tool that can do this? I just haven't found it yet. The end result would be that I can easily keep up to date documentation extracted from code directly inside my documentation org file that contains other things as well.
Asked by Martin (169 rep)
May 22, 2019, 05:15 AM
Last activity: May 22, 2019, 03:39 PM