134134# before actually running Ddoc.
135135# Currently this is used for:
136136# - TOC
137+ # - dynamic TOC generation
138+ # - GRAMMAR overview generation
139+ # - CHANGELOG menu generation
137140# - assert -> writeln magic
138141PWD =$(shell pwd)
139142MAKEFILE =$(firstword $(MAKEFILE_LIST ) )
@@ -282,7 +285,7 @@ DDOC_VARS_PRERELEASE_VERBATIM=$(DDOC_VARS_PRERELEASE) \
282285# Ddoc binaries
283286# ###############################################################################
284287
285- DDOC_BIN: =$G/ddoc
288+ DDOC_BIN: =$G/ddoc_preprocessor
286289
287290# ###############################################################################
288291# Resources
@@ -669,23 +672,24 @@ $W/phobos-prerelease/object.verbatim : $(DMD) $G/changelog/next-version
669672# ###############################################################################
670673
671674.PHONY : phobos-prerelease
672- phobos-prerelease : ${PHOBOS_FILES} druntime-target $(STD_DDOC_PRERELEASE ) $(DDOC_BIN ) $(DMD )
675+ phobos-prerelease : ${PHOBOS_FILES} druntime-target $(STD_DDOC_PRERELEASE ) $(DDOC_BIN ) $(DMD ) \
676+ $G /changelog/next-version
673677 $(MAKE ) --directory=$(PHOBOS_DIR ) -f posix.mak html $(DDOC_VARS_PRERELEASE_HTML ) \
674- DMD=" $( abspath $( DDOC_BIN) ) --compiler=$( DMD) "
678+ DMD=" $( abspath $( DDOC_BIN) ) --compiler=$( abspath $( DMD) ) "
675679
676680phobos-release : ${PHOBOS_FILES} druntime-target $(STD_DDOC_RELEASE ) $(DDOC_BIN ) $(DMD )
677681 $(MAKE ) --directory=$(PHOBOS_DIR ) -f posix.mak html $(DDOC_VARS_RELEASE_HTML ) \
678- DMD=" $( abspath $( DDOC_BIN) ) --compiler=$( DMD) "
682+ DMD=" $( abspath $( DDOC_BIN) ) --compiler=$( abspath $( DMD) ) "
679683
680- phobos-latest : ${PHOBOS_LATEST_FILES} druntime-latest-target $(STD_DDOC_LATEST ) $(DDOC_BIN ) $(DMD )
684+ phobos-latest : ${PHOBOS_LATEST_FILES} druntime-latest-target $(STD_DDOC_LATEST ) $(DDOC_BIN ) $(DMD_LATEST )
681685 $(MAKE ) --directory=$(PHOBOS_LATEST_DIR ) -f posix.mak html $(DDOC_VARS_LATEST_HTML ) \
682- DMD=" $( abspath $( DDOC_BIN) ) --compiler=$( DMD ) "
686+ DMD=" $( abspath $( DDOC_BIN) ) --compiler=$( abspath $( DMD_LATEST ) ) "
683687
684688phobos-prerelease-verbatim : ${PHOBOS_FILES} druntime-target \
685689 $W /phobos-prerelease/index.verbatim
686690$W/phobos-prerelease/index.verbatim : verbatim.ddoc \
687691 $W /phobos-prerelease/object.verbatim \
688- $W /phobos-prerelease/mars.verbatim $G /changelog/next-version
692+ $W /phobos-prerelease/mars.verbatim $G /changelog/next-version $( DMD )
689693 ${MAKE} --directory=${PHOBOS_DIR} -f posix.mak html $(DDOC_VARS_PRERELEASE_VERBATIM ) \
690694 DOC_OUTPUT_DIR=$W /phobos-prerelease-verbatim
691695 $(call CHANGE_SUFFIX,html,verbatim,$W/phobos-prerelease-verbatim)
@@ -838,7 +842,7 @@ test_dspec: dspec_tester.d $(DMD) $(PHOBOS_LIB)
838842 @echo " Test the D Language specification"
839843 $(DMD ) -run $< --compiler=$(DMD )
840844
841- test : $( ASSERT_WRITELN_BIN ) _test test_dspec test/next_version.sh all
845+ test : test_dspec test/next_version.sh all
842846 @echo " Searching for trailing whitespace"
843847 @grep -n ' [[:blank:]]$$' $$(find . -type f -name "*.dd" | grep -v .generated ) ; test $$? -eq 1
844848 @echo " Searching for tabs"
@@ -847,8 +851,8 @@ test: $(ASSERT_WRITELN_BIN)_test test_dspec test/next_version.sh all
847851 @grep -n " UNDEFINED MACRO" $$(find $W -type f -name "*.html" -not -path "$W/phobos/*" ) ; test $$? -eq 1
848852 @echo " Searching for undefined ddoc"
849853 @grep -rn ' [$$](' $$(find $W/phobos-prerelease -type f -name "*.html" ) ; test $$? -eq 1
850- @echo " Executing assert_writeln_magic tests"
851- $<
854+ @echo " Executing ddoc_preprocessor tests"
855+ dub -C ddoc test
852856 @echo " Executing next_version tests"
853857 test/next_version.sh
854858
@@ -933,22 +937,12 @@ $G/contributors_list.ddoc: | $(STABLE_RDMD) $(TOOLS_DIR) $(INSTALLER_DIR)
933937# Custom DDoc wrapper
934938# ------------------
935939#
936- # This allows extending Ddoc files dynamically on-the-fly.
937- # It is currently only used for the specification pages
938- #
939- # It does:
940- # - dynamic TOC generation
941- # - GRAMMAR overview generation
942- # - CHANGELOG menu generation
943- # - Assert -> writeln magic (https://dlang.org/blog/2017/03/08/editable-and-runnable-doc-examples-on-dlang-org)
944- # - This transforms assert(a == b) to writeln(a); // b
945- # - It creates a copy of Phobos to apply the transformations
946- # - All "d" files are piped through the transformator,
947- # other needed files (e.g. posix.mak) get copied over
940+ # This allows extending Ddoc files and D source code files dynamically on-the-fly.
948941# ###############################################################################
949942
950- $(DDOC_BIN ) : ddoc_preprocessor.d | $(STABLE_DMD )
951- $(STABLE_DMD ) -g -of$@ $<
943+ $(DDOC_BIN ) : ddoc/source/preprocessor.d ddoc/source/assert_writeln_magic.d | $(STABLE_DMD )
944+ $(STABLE_DMD_BIN_ROOT ) /dub build --compiler=$(STABLE_DMD ) --root=ddoc && \
945+ mv ddoc/ddoc_preprocessor $@
952946
953947# ###############################################################################
954948# Build and render the DMD man page
0 commit comments