Skip to content

Commit

Permalink
build index file
Browse files Browse the repository at this point in the history
  • Loading branch information
landam committed Jun 16, 2024
1 parent bbbeee2 commit 7b7c244
Show file tree
Hide file tree
Showing 3 changed files with 530 additions and 10 deletions.
9 changes: 9 additions & 0 deletions man/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ IDXSRC = full_index index topics keywords graphical_index manual_gallery class_g

INDICES := $(patsubst %,$(HTMLDIR)/%.html,$(IDXSRC))

# TODO: rename to INDICES_MD
IDXSRC_MD = index
INDICES_MD := $(patsubst %,$(MDDIR)/source/%.md,$(IDXSRC_MD))

ALL_HTML := $(wildcard $(HTMLDIR)/*.*.html)

ifneq (@(type sphinx-build2 > /dev/null),)
Expand All @@ -48,6 +52,7 @@ default: $(DSTFILES)
$(MAKE) $(INDICES)
$(call build,check)
$(MAKE) manpages
$(MAKE) $(INDICES_MD)
$(MAKE) mkdocs

# This must be a separate target so that evaluation of $(MANPAGES)
Expand Down Expand Up @@ -116,6 +121,10 @@ $(HTMLDIR)/index.html: build_index.py build_html.py
$(call build,index)
touch $@

$(MDDIR)/source/index.md: build_index.py build_md.py
$(call build,index)
touch $@

$(HTMLDIR)/keywords.html: $(ALL_HTML)
$(call build_keywords)
touch $@
Expand Down
40 changes: 30 additions & 10 deletions man/build_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,39 @@
import sys
import os

from build_html import *

os.chdir(html_dir)

filename = "index.html"
f = open(filename + ".tmp", "w")
from build_html import (
write_html_header,
write_html_cmd_overview,
write_html_footer,
replace_file,
html_dir,
grass_version,
)
from build_md import (
write_md_header,
write_md_cmd_overview,
write_md_footer,
md_dir,
)

year = None
if len(sys.argv) > 1:
year = sys.argv[1]

write_html_header(f, "GRASS GIS %s Reference Manual" % grass_version, True)
write_html_cmd_overview(f)
write_html_footer(f, "index.html", year)
f.close()

# HTML - to be removed
filename = "index.html"
os.chdir(html_dir)
with open(filename + ".tmp", "w") as f:
write_html_header(f, "GRASS GIS %s Reference Manual" % grass_version, True)
write_html_cmd_overview(f)
write_html_footer(f, "index.html", year)
replace_file(filename)

filename = "index.md"
os.chdir(md_dir)
with open(filename + ".tmp", "w") as f:
write_md_header(f, "GRASS GIS %s Reference Manual" % grass_version, True)
write_md_cmd_overview(f)
write_md_footer(f, "index.md", year)
replace_file(filename)
Loading

0 comments on commit 7b7c244

Please sign in to comment.