Browse Source

Add a test for EDOC_SRC_DIRS and tweak the feature a bit

Loïc Hoguin 8 years ago
parent
commit
ecd4344f3e
2 changed files with 34 additions and 11 deletions
  1. 10 10
      plugins/edoc.mk
  2. 24 1
      test/plugin_edoc.mk

+ 10 - 10
plugins/edoc.mk

@@ -6,28 +6,28 @@
 # Configuration.
 
 EDOC_OPTS ?=
-EDOC_SRC_DIRS ?= $(ALL_APPS_DIRS) $(ALL_DEPS_DIRS)
+EDOC_SRC_DIRS ?=
 
-# TODO: use double-quote instead of single + atom_to_list
-#       The problem is in correctly escaping double-quotes
 define edoc.erl
-	SrcPaths = lists:foldl(fun (P, Acc) ->
-	                         filelib:wildcard(atom_to_list(P) ++ "/{src,c_src}") ++ Acc
-	                       end, [], [$(call comma_list,$(patsubst %,'%',$(EDOC_SRC_DIRS)))]),
-	DefaultOpts = [ {source_path, SrcPaths}
-	               ,{subpackages, false} ],
+	SrcPaths = lists:foldl(fun(P, Acc) ->
+		filelib:wildcard(atom_to_list(P) ++ "/{src,c_src}") ++ Acc
+	end, [], [$(call comma_list,$(patsubst %,'%',$(EDOC_SRC_DIRS)))]),
+	DefaultOpts = [{source_path, SrcPaths}, {subpackages, false}],
 	edoc:application($(1), ".", [$(2)] ++ DefaultOpts),
 	halt(0).
 endef
 
 # Core targets.
-docs:: distclean-edoc edoc
+
+ifneq ($(strip $(EDOC_SRC_DIRS)$(wildcard doc/overview.edoc)),)
+docs:: edoc
+endif
 
 distclean:: distclean-edoc
 
 # Plugin-specific targets.
 
-edoc: doc-deps
+edoc: distclean-edoc doc-deps
 	$(gen_verbose) $(call erlang,$(call edoc.erl,$(PROJECT),$(EDOC_OPTS)))
 
 distclean-edoc:

+ 24 - 1
test/plugin_edoc.mk

@@ -1,6 +1,6 @@
 # EDoc plugin.
 
-EDOC_CASES = build docs no-overview opts
+EDOC_CASES = build docs no-overview opts src-dirs
 EDOC_TARGETS = $(addprefix edoc-,$(EDOC_CASES))
 
 .PHONY: edoc $(EDOC_TARGETS)
@@ -110,3 +110,26 @@ edoc-opts: build clean
 	$t test -f $(APP)/doc/README.md
 	$t test -f $(APP)/doc/$(APP)_app.md
 	$t test -f $(APP)/doc/$(APP)_sup.md
+
+edoc-src-dirs: build clean
+
+	$i "Create a multi application repository with a root application"
+	$t mkdir $(APP)/
+	$t cp ../erlang.mk $(APP)/
+	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v
+
+	$i "Create a new application my_app"
+	$t $(MAKE) -C $(APP) new-app in=my_app $v
+
+	$i "Add apps directories to the list of EDoc source directories"
+	$t echo 'EDOC_SRC_DIRS = $$(ALL_APPS_DIRS)' >> $(APP)/Makefile
+
+	$i "Run EDoc"
+	$t $(MAKE) -C $(APP) edoc $v
+
+	$i "Check that the generated documentation includes modules from both apps"
+	$t test -f $(APP)/doc/index.html
+	$t test -f $(APP)/doc/$(APP)_app.html
+	$t test -f $(APP)/doc/$(APP)_sup.html
+	$t test -f $(APP)/doc/my_app_app.html
+	$t test -f $(APP)/doc/my_app_sup.html