msxbuild/lib/make/mb_doc.mk
Willem Cazander 65b40a74cb
All checks were successful
Run test asserts / Test-Asserts (push) Successful in 5s
Renamed dos packages and new help system.
2024-07-02 03:27:14 +02:00

108 lines
4.5 KiB
Makefile

MB_DOC_HELP_PROJECT ?= ""
MB_DOC_HELP_TARGET ?= ""
MB_DOC_HELP_VARIABLE ?= ""
MB_DOC_HELP_FUNCTION ?= ""
MB_DOC_TXT_BUILD_ALL := "Use 'make help' for possible targets and documention."
MB_DOC_TXT_BUILD_PROJECT := "Welcome to the MSXBUILD help system.\\n\\nFor detailed help use one of the following targets;\\n"
MB_DOC_TXT_BUILD_TARGET := "Build one of the following make targets;\\n"
MB_DOC_TXT_BUILD_VARIABLE := "Documention of the MSXBUILD variables;\\n"
MB_DOC_TXT_BUILD_FUNCTION := "Documention of the MSXBUILD functions;\\n"
MB_DOC_FORMAT ?= txt
MB_DOC_HELP_VARIABLE += $(call mb_doc_variable,MB_DOC_FORMAT,"Output format of documention$(MB_CHAR_COMMA) only 'txt' is supported currently.",$(MB_DOC_FORMAT))
define _mb_doc_xml_open
$(MB_CHAR_LT)$(1)$(if $(2), $(2)=\"$(3)\")$(MB_CHAR_GT)
endef
define _mb_doc_xml_close
$(MB_CHAR_LT)/$(1)$(MB_CHAR_GT)
endef
define _mb_doc_xml_tag_value
$(if $(2),$(call _mb_doc_xml_open,$(1))$(MB_CHAR_CDATA_START)$(2)$(MB_CHAR_CDATA_END)$(call _mb_doc_xml_close,$(1)))
endef
define _mb_doc_function_txt
"* "$(1)$(if $(3), $(3))$(if $(2),\\n\\t$(2)\\n)\\n
endef
define _mb_doc_function_xml
\\n\\t$(call _mb_doc_xml_open,function,name,$(1))\\n\\t\\t$(call _mb_doc_xml_tag_value,args,$(3))\\n\\t\\t$(call _mb_doc_xml_tag_value,desc,$(2))\\n\\t$(call _mb_doc_xml_close,function)
endef
define mb_doc_function
$(call _mb_doc_function_$(MB_DOC_FORMAT),$(1),$(2),$(3))
endef
MB_DOC_HELP_FUNCTION += $(call mb_doc_function,mb_doc_function,"Prints formatted documention of an function.","<name> [desc] [args]")
define _mb_doc_variable_txt
"* "$(1)=$(subst \\n,\\\n,$(3))\\n$(if $(2),\\t$(2)\\n)\\n
endef
define _mb_doc_variable_xml
\\n\\t$(call _mb_doc_xml_open,variable,name,$(1))\\n\\t\\t$(call _mb_doc_xml_tag_value,value,$(3))\\n\\t\\t$(call _mb_doc_xml_tag_value,desc,$(2))\\n\\t$(call _mb_doc_xml_close,variable)
endef
define mb_doc_variable
$(call _mb_doc_variable_$(MB_DOC_FORMAT),$(1),$(2),$(3))
endef
MB_DOC_HELP_FUNCTION += $(call mb_doc_function,mb_doc_variable,"Prints formatted documention of an variable.","<name> [desc] [value]")
# "* "$(1)$(if $(2),\\n\\t$(2))$(if $(3),\\n\\t\\tDEPS: $(3))\\n
define _mb_doc_target_txt
"* "$(1)$(if $(2),\\n\\t$(2))\\n\\n
endef
define _mb_doc_target_xml
\\n\\t$(call _mb_doc_xml_open,target,name,$(1))\\n\\t\\t$(call _mb_doc_xml_tag_value,desc,$(2))\\n\\t$(call _mb_doc_xml_close,target)
endef
define mb_doc_target
$(call _mb_doc_target_$(MB_DOC_FORMAT),$(1),$(2))
endef
MB_DOC_HELP_FUNCTION += $(call mb_doc_function,mb_doc_target,"Prints formatted documention of an target.","<name> [desc]")
define _mb_doc_project_txt
"* "$(1)\\n
endef
define _mb_doc_project_xml
\\n$(call _mb_doc_xml_open,project)\\n\\t$(call _mb_doc_xml_tag_value,name,$(1))\\n$(call _mb_doc_xml_close,project)
endef
define mb_doc_project
$(call _mb_doc_project_$(MB_DOC_FORMAT),$(1))
endef
MB_DOC_HELP_FUNCTION += $(call mb_doc_function,mb_doc_project,"Prints formatted documention of an project (help).","<name>")
define mb_doc_show_help@all
@echo $(MB_DOC_TXT_BUILD_ALL)
endef
MB_DOC_HELP_FUNCTION += $(call mb_doc_function,mb_doc_show_help@all,"Displays text for 'make'")
define mb_doc_show_help@project
@echo $(MB_DOC_TXT_BUILD_PROJECT)
@echo $(MB_DOC_HELP_PROJECT)
endef
MB_DOC_HELP_FUNCTION += $(call mb_doc_function,mb_doc_show_help@project,"Displays text for 'make help'")
define mb_doc_show_help@target
$(if $(filter txt,$(MB_DOC_FORMAT)),@echo $(MB_DOC_TXT_BUILD_TARGET))
$(if $(filter xml,$(MB_DOC_FORMAT)),@echo $(call _mb_doc_xml_open,firemake))
@echo $(MB_DOC_HELP_TARGET)
$(if $(filter xml,$(MB_DOC_FORMAT)),@echo $(call _mb_doc_xml_close,firemake))
endef
MB_DOC_HELP_FUNCTION += $(call mb_doc_function,mb_doc_show_help@target,"Displays text for 'make help@target'")
define mb_doc_show_help@variable
$(if $(filter txt,$(MB_DOC_FORMAT)),@echo $(MB_DOC_TXT_BUILD_VARIABLE))
$(if $(filter xml,$(MB_DOC_FORMAT)),@echo $(call _mb_doc_xml_open,firemake))
@echo $(MB_DOC_HELP_VARIABLE)
$(if $(filter xml,$(MB_DOC_FORMAT)),@echo $(call _mb_doc_xml_close,firemake))
endef
MB_DOC_HELP_FUNCTION += $(call mb_doc_function,mb_doc_show_help@variable,"Displays text for 'make help@variable'")
define mb_doc_show_help@function
$(if $(filter txt,$(MB_DOC_FORMAT)),@echo $(MB_DOC_TXT_BUILD_FUNCTION))
$(if $(filter xml,$(MB_DOC_FORMAT)),@echo $(call _mb_doc_xml_open,firemake))
@echo $(MB_DOC_HELP_FUNCTION)
$(if $(filter xml,$(MB_DOC_FORMAT)),@echo $(call _mb_doc_xml_close,firemake))
endef
MB_DOC_HELP_FUNCTION += $(call mb_doc_function,mb_doc_show_help@function,"Displays text for 'make help@function'")