Hi Stephen! On 3/20/22 23:27, Stephen Kitt wrote: > Hi Alex, > > On Sun, 20 Mar 2022 21:34:47 +0100, "Alejandro Colomar (man-pages)" > I’ve been working on something similar, slightly further along (the linting > targets work). I've been adding code for linting this evening too. Currently I'm compiling and linking the programs extracted. I only did it with membarrier.2 for now, and I've already fixed a line. I also plan to add some static analyzers too, such as iwyu(1), clang-tidy(1), or checkpatch.pl and some others. You could check my 'lint' branch here: <http://www.alejandro-colomar.es/src/alx/linux/man-pages/man-pages.git/log/?h=lint> Compare that with what you have, and we can develop some mix of both. With what I have, you need to run: make build-src && make build-ld > The extraction scripts could do with some improvement, but the > Makefile changes are small: > > # Check that example programs include in man pages really build > Makefile.examples: $(MANPAGES) > scripts/list-example-files $^ > $@ > > include Makefile.examples > > # Sources are listed as well as objects to ensure we update all source files > # CPPFLAGS and TARGET_ARCH are defined to avoid warnings > .PHONY: check-example-programs > check-example-programs: CFLAGS = -Wall > check-example-programs: CPPFLAGS = > check-example-programs: TARGET_ARCH = > check-example-programs: $(EXAMPLE_SRCS) $(EXAMPLE_OBJS) > > .PHONY: clean-example-programs > clean-example-programs: > rm -f $(EXAMPLE_SRCS) $(EXAMPLE_OBJS) > > > scripts/list-example-files builds a separate Makefile to extract all the > programs, which ends up looking like > > /home/steve/man-pages/man1/memusage.c: /home/steve/man-pages/man1/memusage.1 > scripts/extract-example-files $< > > /home/steve/man-pages/man1/prog.c /home/steve/man-pages/man1/libdemo.c: /home/steve/man-pages/man1/sprof.1 > scripts/extract-example-files $< I like the idea of autogenerating and including a makefile, which allows listing the example programs in the process. In my current makefile, I need to run make build-src before any further actions on those files, since I don't know them at the time of setting variables. I may take some bits from here. > > > The scripts are attached. The patterns used to identify source code are close > to those already present: .EX/.EE introduced by “Program source” (in which > case the source code is extracted to a C file named after the man page) or by > a > > \." Example file > > comment which can optionally name the file. Those scripts seem a bit messy, due to the problem of not having a standardized comment. Are they reliable? Or are there false negatives or positives? > > This has identified some more man pages which need fixes to their example > code, I’ll send patches tomorrow. Okay. Cheers, Alex -- Alejandro Colomar Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/ http://www.alejandro-colomar.es/