Skip to content

Commit c962db2

Browse files
* builds/*/*: Prepare build system for docwriter.
Add checks, rules and variables to the build system for docwriter. * Running `make' will warn if Python/PIP/docwriter are not available. * Running `make refdoc' will generate static documentation site on the current Python environment. * Running `make refdoc-venv' will generate static documentation site using a virtual environment, using the pip package `virtualenv'.
1 parent 195728d commit c962db2

10 files changed

Lines changed: 103 additions & 11 deletions

File tree

Jamfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,13 @@ rule RefDoc
208208

209209
actions RefDoc
210210
{
211-
python $(FT2_SRC)/tools/docmaker/docmaker.py
211+
python -m docwriter
212212
--prefix=ft2
213213
--title=FreeType-2.9.1
214214
--output=$(DOC_DIR)
215215
$(FT2_INCLUDE)/freetype/*.h
216216
$(FT2_INCLUDE)/freetype/config/*.h
217+
$(FT2_INCLUDE)/freetype/cache/*.h
217218
}
218219

219220
RefDoc refdoc ;

builds/ansi/ansi-def.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ SEP := /
1919
BUILD_DIR := $(TOP_DIR)/builds/ansi
2020
PLATFORM := ansi
2121

22+
# This is used for `make refdoc' and `make refdoc-venv'
23+
#
24+
BIN := bin
2225

2326
# The directory where all library files are placed.
2427
#

builds/beos/beos-def.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ SEP := /
2121
BUILD_DIR := $(TOP_DIR)/builds/beos
2222
PLATFORM := beos
2323

24+
# This is used for `make refdoc' and `make refdoc-venv'
25+
#
26+
BIN := bin
2427

2528
# The directory where all library files are placed.
2629
#

builds/dos/dos-def.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ SEP := $(strip \ )
1919
BUILD_DIR := $(TOP_DIR)/builds/dos
2020
PLATFORM := dos
2121

22+
# This is used for `make refdoc' and `make refdoc-venv'
23+
#
24+
BIN := Scripts
2225

2326
# The executable file extension (for tools), *with* leading dot.
2427
#

builds/freetype.mk

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
# The targets `objects' and `library' are defined at the end of this
7676
# Makefile after all other rules have been included.
7777
#
78-
.PHONY: single multi objects library refdoc
78+
.PHONY: single multi objects library refdoc refdoc-venv
7979

8080
# default target -- build single objects and library
8181
#
@@ -289,18 +289,52 @@ objects: $(OBJECTS_LIST)
289289

290290
library: $(PROJECT_LIBRARY)
291291

292-
292+
# Run `docwriter' in the current Python environment.
293293
# Option `-B' disables generation of .pyc files (available since python 2.6)
294294
#
295-
refdoc:
296-
python -B $(SRC_DIR)/tools/docmaker/docmaker.py \
297-
--prefix=ft2 \
298-
--title=FreeType-$(version) \
299-
--output=$(DOC_DIR) \
300-
$(PUBLIC_DIR)/*.h \
301-
$(PUBLIC_DIR)/config/*.h \
302-
$(PUBLIC_DIR)/cache/*.h
303295

296+
PYTHON ?= python
297+
PIP ?= pip
298+
299+
refdoc:
300+
@echo Running docwriter...
301+
$(PYTHON) -m docwriter \
302+
--prefix=ft2 \
303+
--title=FreeType-$(version) \
304+
--output=$(DOC_DIR) \
305+
$(PUBLIC_DIR)/*.h \
306+
$(PUBLIC_DIR)/config/*.h \
307+
$(PUBLIC_DIR)/cache/*.h
308+
@echo Building static site...
309+
cd $(DOC_DIR) && mkdocs build
310+
@echo Done.
311+
312+
# Variables for running refdoc with Python's `virtualenv'. The env is
313+
# created in `DOC_DIR/env' and is gitignored.
314+
# We still need to cd into `DOC_DIR' to build mkdocs because paths in
315+
# mkdocs.yml are relative to cwd.
316+
#
317+
VENV_NAME := env
318+
VENV_DIR := $(DOC_DIR)$(SEP)$(VENV_NAME)
319+
ENV_PYTHON := $(VENV_DIR)$(SEP)$(BIN)$(SEP)$(PYTHON)
320+
ENV_PIP := $(VENV_DIR)$(SEP)$(BIN)$(SEP)$(PIP)
321+
322+
refdoc-venv:
323+
@echo Setting up virtualenv for Python...
324+
virtualenv $(VENV_DIR)
325+
@echo Installing docwriter...
326+
$(ENV_PIP) install docwriter
327+
@echo Running docwriter...
328+
$(ENV_PYTHON) -m docwriter \
329+
--prefix=ft2 \
330+
--title=FreeType-$(version) \
331+
--output=$(DOC_DIR) \
332+
$(PUBLIC_DIR)/*.h \
333+
$(PUBLIC_DIR)/config/*.h \
334+
$(PUBLIC_DIR)/cache/*.h
335+
@echo Building static site...
336+
cd $(DOC_DIR) && $(VENV_NAME)$(SEP)$(BIN)$(SEP)python -m mkdocs build
337+
@echo Done.
304338

305339
.PHONY: clean_project_std distclean_project_std
306340

builds/os2/os2-def.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ SEP := $(strip \ )
1919
BUILD_DIR := $(TOP_DIR)/builds/os2
2020
PLATFORM := os2
2121

22+
# This is used for `make refdoc' and `make refdoc-venv'
23+
#
24+
BIN := Scripts
25+
2226
# The executable file extension (for tools), *with* leading dot.
2327
#
2428
E := .exe

builds/unix/configure.raw

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,25 @@ case "$CFLAGS" in
968968
;;
969969
esac
970970

971+
# Check for python and docwriter
972+
973+
AC_CHECK_PROGS([PYTHON], [python3 python2 python], [missing])
974+
have_docwriter=no
975+
if test "x$PYTHON" != "xmissing"; then
976+
AC_CHECK_PROGS([PIP], [pip3 pip2 pip], [missing])
977+
978+
if test "x$PIP" != "xmissing"; then
979+
AC_MSG_CHECKING([for \`docwriter' Python module])
980+
$PIP show -q docwriter
981+
if test "x$?" = "x0"; then
982+
have_docwriter=yes
983+
AC_MSG_RESULT([yes])
984+
else
985+
AC_MSG_RESULT([no])
986+
fi
987+
fi
988+
fi
989+
971990

972991
# entries in Requires.private are separated by commas;
973992
REQUIRES_PRIVATE="$zlib_reqpriv, \
@@ -1112,4 +1131,15 @@ Library configuration:
11121131
harfbuzz: $have_harfbuzz
11131132
])
11141133

1134+
# Warn if docwriter is not installed
1135+
1136+
if test $have_docwriter = no; then
1137+
AC_MSG_NOTICE([
1138+
Warning: \`make refdoc' will fail since pip package \`docwriter' is not
1139+
installed. To install, run \`$PIP install docwriter', or to use a python
1140+
virtual environment, run \`make refdoc-venv' (requires pip package
1141+
\`virtualenv').
1142+
])
1143+
fi
1144+
11151145
# end of configure.raw

builds/unix/unix-def.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ DELDIR := rm -rf
2121
CAT := cat
2222
SEP := /
2323

24+
# This is used for `make refdoc' and `make refdoc-venv'
25+
#
26+
PYTHON := @PYTHON@
27+
PIP := @PIP@
28+
BIN := bin
29+
2430
# this is used for `make distclean' and `make install'
2531
OBJ_BUILD ?= $(BUILD_DIR)
2632

builds/unix/unixddef.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ DELETE := rm -f
2323
CAT := cat
2424
SEP := /
2525

26+
# This is used for `make refdoc' and `make refdoc-venv'
27+
#
28+
BIN := bin
29+
2630
# we use a special devel ftoption.h
2731
DEVEL_DIR := $(TOP_DIR)/devel
2832

builds/windows/win32-def.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ SEP := $(strip \ )
1919
BUILD_DIR := $(TOP_DIR)/builds/windows
2020
PLATFORM := windows
2121

22+
# This is used for `make refdoc' and `make refdoc-venv'
23+
#
24+
BIN := Scripts
25+
2226
# The executable file extension (for tools). NOTE: WE INCLUDE THE DOT HERE !!
2327
#
2428
E := .exe

0 commit comments

Comments
 (0)