make/Javadoc.gmk
changeset 44734 70bbd6884287
parent 44733 6505f00be6f2
child 44826 7a887996ee84
--- a/make/Javadoc.gmk	Sun Apr 23 21:10:32 2017 +0200
+++ b/make/Javadoc.gmk	Sun Apr 23 21:34:02 2017 +0200
@@ -363,6 +363,38 @@
   ) \
 )
 
+ifeq ($(ENABLE_FULL_DOCS), true)
+  # For all markdown files in $module/share/specs directories, convert them to
+  # html.
+  MARKDOWN_SPEC_FILTER := %.md
+
+  # Macro for SetupCopyFiles that converts from markdown to html using pandoc.
+  define markdown-to-html
+	$(call MakeDir, $(@D))
+	$(RM) $@
+	$(PANDOC) -t html -s -o $@ $<
+  endef
+
+  rename-md-to-html = \
+      $(patsubst %.md,%.html,$1)
+
+  $(foreach m, $(ALL_MODULES), \
+    $(eval SPECS_$m := $(call FindModuleSpecsDirs, $m)) \
+    $(if $(SPECS_$m), \
+      $(eval $(call SetupCopyFiles, CONVERT_MARKDOWN_$m, \
+          SRC := $(SPECS_$m), \
+          FILES := $(filter $(MARKDOWN_SPEC_FILTER), $(call CacheFind, $(SPECS_$m))), \
+          DEST := $(JAVADOC_OUTPUTDIR)/specs/, \
+          MACRO := markdown-to-html, \
+          NAME_MACRO := rename-md-to-html, \
+          LOG_ACTION := Converting from markdown, \
+      )) \
+      $(eval JDK_SPECS_TARGETS += $(CONVERT_MARKDOWN_$m)) \
+    ) \
+  )
+
+endif
+
 # Special treatment for generated documentation
 
 JDWP_PROTOCOL := $(SUPPORT_OUTPUTDIR)/gensrc/jdk.jdi/jdwp-protocol.html