From 088450cbf500e86e1dc0fa72f0869d2385bffa74 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 17 Sep 2017 15:01:15 -0700 Subject: [PATCH] Factor out script to build commands.hdr As part of factoring out the documentation building parts of the fish build, add a new file build_commands_hdr.sh that builds the commands.hdr file. Invoke it from both the Makefile and CMake build. --- CMakeFiles/Docs.cmake | 46 ++++++++++++++++++++++++++++++- Makefile.in | 17 ++---------- build_tools/build_commands_hdr.sh | 20 ++++++++++++++ 3 files changed, 67 insertions(+), 16 deletions(-) create mode 100755 build_tools/build_commands_hdr.sh diff --git a/CMakeFiles/Docs.cmake b/CMakeFiles/Docs.cmake index becc2c952..a8723dbd5 100644 --- a/CMakeFiles/Docs.cmake +++ b/CMakeFiles/Docs.cmake @@ -4,7 +4,21 @@ FILE(GLOB COMPLETIONS_DIR_FILES share/completions/*.fish) # Files in ./share/functions/ FILE(GLOB FUNCTIONS_DIR_FILES share/functions/*.fish) -# Build lexicon_filter +# Files in doc_src +FILE(GLOB DOC_SRC_FILES doc_src/*) + +# .txt files in doc_src +FILE(GLOB HELP_SRC doc_src/*.txt) + +# These files are the source files, they contain a few @FOO@-style substitutions. +# Note that this order defines the order that they appear in the documentation. +SET(HDR_FILES_SRC doc_src/index.hdr.in doc_src/tutorial.hdr doc_src/design.hdr + doc_src/license.hdr doc_src/commands.hdr.in doc_src/faq.hdr) + +# These are the generated result files. +STRING(REPLACE ".in" "" HDR_FILES ${HDR_FILES_SRC}) + +# Build lexicon_filter. ADD_CUSTOM_COMMAND(OUTPUT lexicon_filter COMMAND build_tools/build_lexicon_filter.sh ${CMAKE_CURRENT_SOURCE_DIR}/share/completions/ @@ -17,3 +31,33 @@ ADD_CUSTOM_COMMAND(OUTPUT lexicon_filter doc_src/commands.hdr lexicon_filter.in share/functions/__fish_config_interactive.fish build_tools/build_lexicon_filter.sh) + +# +# commands.dr collects documentation on all commands, functions and +# builtins +# + +ADD_CUSTOM_COMMAND(OUTPUT doc_src/commands.hdr + COMMAND build_tools/build_commands_hdr.sh ${HELP_SRC} + < doc_src/commands.hdr.in + > ${CMAKE_CURRENT_BINARY_DIR}/doc_src/commands.hdr + DEPENDS ${DOC_SRC_FILES} doc_src/commands.hdr.in build_tools/build_commands_hdr.sh) + +# doc.h is a compilation of the various snipptes of text used both for +# the user documentation and for internal help functions into a single +# file that can be parsed by Doxygen to generate the user +# documentation. +ADD_CUSTOM_COMMAND(OUTPUT doc.h + COMMAND cat ${HDR_FILES} > ${CMAKE_CURRENT_BINARY_DIR}/doc.h + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${HDR_FILES}) + +ADD_CUSTOM_TARGET(doc + COMMAND "(cat Doxyfile.user; echo INPUT_FILTER=./lexicon_filter; echo PROJECT_NUMBER=${FISH_BUILD_VERSION} |\ + /usr/bin/env sed 's/-.*//') | doxygen - && touch user_doc)" + DEPENDS ${HDR_FILES_SRC} Doxyfile.user ${DOC_SRC_FILES} doc.h $(HDR_FILES) lexicon_filter) + +# doc: $(HDR_FILES_SRC) Doxyfile.user $(HTML_SRC) $(HELP_SRC) doc.h $(HDR_FILES) lexicon_filter +# @echo " doxygen $(em)user_doc$(sgr0)" +# $v (cat Doxyfile.user; echo INPUT_FILTER=./lexicon_filter; echo PROJECT_NUMBER=$(FISH_BUILD_VERSION) | $(SED) "s/-.*//") | doxygen - && touch user_doc +# $v rm -f $(wildcard $(addprefix ./user_doc/html/,arrow*.png bc_s.png bdwn.png closed.png doc.png folder*.png ftv2*.png nav*.png open.png splitbar.png sync_*.png tab*.* doxygen.* dynsections.js jquery.js pages.html)) \ No newline at end of file diff --git a/Makefile.in b/Makefile.in index 74d7ceac6..ec25166f2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -403,21 +403,8 @@ test_interactive: $(call filter_up_to,test_interactive,$(active_test_goals)) # commands.hdr collects documentation on all commands, functions and # builtins # -doc_src/commands.hdr:$(HELP_SRC) doc_src/commands.hdr.in | - @echo " CAT AWK $(em)$@$(sgr0)" - $v rm -f command_list.tmp command_list_toc.tmp $@ - $v for i in `printf "%s\n" $(HELP_SRC) | LC_ALL=C.UTF-8 sort`; do \ - echo "
" >>command_list.tmp; \ - cat $$i >>command_list.tmp; \ - echo >>command_list.tmp; \ - echo >>command_list.tmp; \ - NAME=`basename $$i .txt`; \ - echo '- '$$NAME'' >> command_list_toc.tmp; \ - echo "Back to command index". >>command_list.tmp; \ - done - $v mv command_list.tmp command_list.txt - $v mv command_list_toc.tmp command_list_toc.txt - $v cat $@.in | $(AWK) '{if ($$0 ~ /@command_list_toc@/) { system("cat command_list_toc.txt"); } else if ($$0 ~ /@command_list@/){ system("cat command_list.txt");} else{ print $$0;}}' >$@ +doc_src/commands.hdr:$(HELP_SRC) doc_src/commands.hdr.in build_tools/build_commands_hdr.sh + build_tools/build_commands_hdr.sh ${HELP_SRC} < doc_src/commands.hdr.in > $@ toc.txt: $(HDR_FILES:index.hdr=index.hdr.in) | show-SED @echo " SED $(em)$@$(sgr0)" diff --git a/build_tools/build_commands_hdr.sh b/build_tools/build_commands_hdr.sh new file mode 100755 index 000000000..3a89a073b --- /dev/null +++ b/build_tools/build_commands_hdr.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# Builds the commands.hdr file. +# Usage: build_commands_hdr.sh ${HELP_SRC} < commands_hdr.in > commands.hdr + +rm -f command_list.tmp command_list_toc.tmp +for i in `printf "%s\n" $@ | LC_ALL=C.UTF-8 sort`; do + echo "
" >>command_list.tmp; + cat $i >>command_list.tmp; + echo >>command_list.tmp; + echo >>command_list.tmp; + NAME=`basename $i .txt`; + echo '- '$NAME'' >> command_list_toc.tmp; + echo "Back to command index". >>command_list.tmp; +done +mv command_list.tmp command_list.txt +mv command_list_toc.tmp command_list_toc.txt +/usr/bin/env awk '{if ($0 ~ /@command_list_toc@/) { system("cat command_list_toc.txt"); } + else if ($0 ~ /@command_list@/){ system("cat command_list.txt");} + else{ print $0;}}'