Make pandoc conversion of man pages work again. ihse-manpages-branch
authorihse
Wed, 10 Oct 2018 10:12:15 +0200
branchihse-manpages-branch
changeset 56950 55725429863a
parent 56893 2d3320d628a0
child 56951 79c99e08deb2
Make pandoc conversion of man pages work again.
make/Docs.gmk
make/Main.gmk
make/common/ProcessMarkdown.gmk
--- a/make/Docs.gmk	Tue Sep 18 14:27:31 2018 +0200
+++ b/make/Docs.gmk	Wed Oct 10 10:12:15 2018 +0200
@@ -570,7 +570,7 @@
               FILES := $(filter %.1, $(call CacheFind, $d)), \
               DEST := $(JAVADOC_OUTPUTDIR)/man/man1, \
           )) \
-          $(eval JDK_SPECS_TARGETS += $(COPY_MAN_$m)) \
+          $(eval MAN_PAGE_TARGETS += $(COPY_MAN_$m)) \
         ) \
       ) \
     )
@@ -580,17 +580,37 @@
       $(eval MAN_$m := $(call FindModuleManDirs, $m)) \
       $(foreach d, $(MAN_$m), \
         $(if $(filter %.md, $(call CacheFind, $d)), \
-          $(eval $(call SetupProcessMarkdown, CONVERT_MARKDOWN_MAN_$m_$d, \
+        $(eval $m_$d_NAME := CONVERT_MAN_TO_TROFF_$m_$(strip $(call RelativePath, $d, $(TOPDIR)))) \
+          $(eval $(call SetupProcessMarkdown, $($m_$d_NAME), \
               SRC := $d, \
               FILES := $(filter %.md, $(call CacheFind, $d)), \
-              DEST := $(JAVADOC_OUTPUTDIR)/man/man1, \
+              DEST := $(DOCS_OUTPUTDIR)/man/man1, \
               FORMAT := man, \
-              FILE_EXT := .1, \
           )) \
         ) \
-        $(eval JDK_SPECS_TARGETS += $(CONVERT_MARKDOWN_MAN_$m_$d)) \
+        $(eval MAN_PAGE_TARGETS += $($($m_$d_NAME))) \
       ) \
     )
+
+    # Generate html pages ("man spec") from markdown
+    $(foreach m, $(ALL_MODULES), \
+      $(eval MAN_$m := $(call FindModuleManDirs, $m)) \
+      $(foreach d, $(MAN_$m), \
+        $(if $(filter %.md, $(call CacheFind, $d)), \
+        $(eval $m_$d_NAME := CONVERT_MAN_TO_HTML_$m_$(strip $(call RelativePath, $d, $(TOPDIR)))) \
+          $(eval $(call SetupProcessMarkdown, $($m_$d_NAME), \
+              SRC := $d, \
+              FILES := $(filter %.md, $(call CacheFind, $d)), \
+              DEST := $(DOCS_OUTPUTDIR)/specs/man, \
+              CSS := $(GLOBAL_SPECS_DEFAULT_CSS_FILE), \
+          )) \
+        ) \
+        $(eval MAN_PAGE_TARGETS += $($($m_$d_NAME))) \
+      ) \
+    )
+
+  JDK_SPECS_TARGETS += $(MAN_PAGE_TARGETS)
+  
   endif
 endif
 
@@ -644,6 +664,8 @@
 
 docs-jdk-index: $(JDK_INDEX_TARGETS)
 
+man-pages: $(MAN_PAGE_TARGETS)
+
 docs-zip: $(ZIP_TARGETS)
 
 all: docs-jdk-api-javadoc docs-jdk-api-modulegraph docs-javase-api-javadoc \
--- a/make/Main.gmk	Tue Sep 18 14:27:31 2018 +0200
+++ b/make/Main.gmk	Wed Oct 10 10:12:15 2018 +0200
@@ -380,6 +380,9 @@
 docs-jdk-index:
 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-jdk-index)
 
+docs-man-pages:
+	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk man-pages)
+
 docs-zip:
 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Docs.gmk docs-zip)
 
@@ -392,7 +395,7 @@
 ALL_TARGETS += docs-jdk-api-javadoc docs-jdk-api-modulegraph \
     docs-javase-api-javadoc docs-javase-api-modulegraph \
     docs-reference-api-javadoc docs-reference-api-modulegraph docs-jdk-specs \
-    docs-jdk-index docs-zip update-build-docs update-x11wrappers
+    docs-jdk-index docs-man-pages docs-zip update-build-docs update-x11wrappers
 
 ################################################################################
 # Cross compilation support
--- a/make/common/ProcessMarkdown.gmk	Tue Sep 18 14:27:31 2018 +0200
+++ b/make/common/ProcessMarkdown.gmk	Wed Oct 10 10:12:15 2018 +0200
@@ -1,4 +1,4 @@
-# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -49,10 +49,10 @@
       $$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER).vardeps)
 
 $$($1_$2_OUTPUT_FILE): $$($1_SRC)/$2 $$($1_$2_VARDEPS_FILE)
-	$$(call LogInfo, Converting $2 to html)
+	$$(call LogInfo, Converting $2 to $$($1_TO_TYPE))
 	$$(call MakeDir, $$($1_$2_TARGET_DIR) $$(SUPPORT_OUTPUTDIR)/markdown)
 	$$(call ExecuteWithLog, $$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER), \
-	    $$(PANDOC) $$($1_OPTIONS) -f markdown -t html5 --standalone \
+	    $$(PANDOC) $$($1_OPTIONS) -f markdown -t $$($1_TO_TYPE) --standalone \
 	    $$($1_$2_CSS_OPTION) $$($1_$2_OPTIONS) '$$<' -o '$$@')
         ifneq ($$(findstring $$(LOG_LEVEL), debug trace),)
 	TOO_LONG_LINES=`$$(GREP) -E -e '^.{80}.+$$$$' $$<` || true ; \
@@ -113,11 +113,17 @@
     # FIXME: We also need a pandoc filter that removes link targets for internal
     # links (#options)...
     # FIXME: Perhaps it should also make h1 headings ALL CAPS.
-  endif
-
-  # If no file extension is specified, default to '.html'.
-  ifeq ($$($1_FILE_EXT), )
-    $1_FILE_EXT := .html
+    $1_TO_TYPE := man
+    # If no file extension is specified, default to '.1'.
+    ifeq ($$($1_FILE_EXT), )
+      $1_FILE_EXT := .1
+    endif
+  else ifeq ($$($1_FORMAT), html)
+    # If no file extension is specified, default to '.html'.
+    $1_TO_TYPE := html5
+    ifeq ($$($1_FILE_EXT), )
+      $1_FILE_EXT := .html
+    endif
   endif
 
   # Remove any trailing slash from SRC and DEST