You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "scholarsmate (via GitHub)" <gi...@apache.org> on 2023/09/28 19:32:24 UTC

[GitHub] [daffodil-vscode] scholarsmate commented on a diff in pull request #862: add Makefile to create docx documents from the wiki

scholarsmate commented on code in PR #862:
URL: https://github.com/apache/daffodil-vscode/pull/862#discussion_r1340587023


##########
doc/Makefile:
##########
@@ -0,0 +1,49 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Requires: make, git, sed, and pandoc
+
+# Directory containing the wiki markdown files
+SRCDIR := .wiki/
+
+# Filter out .md files starting with underscore and generate corresponding .docx filenames
+DOCX = $(addsuffix .docx, $(filter-out _%, $(basename $(notdir $(wildcard $(SRCDIR)*.md)))))
+
+# Function to sanitize filenames
+sanitize = $(shell echo $(1) | sed -e 's/[^a-zA-Z0-9.\-]/_/g' -e 's/__*/_/g' -e 's/_\-/-/g')
+
+# Target to clone the git wiki repository
+$(SRCDIR):
+	git clone https://github.com/apache/daffodil-vscode.wiki.git $(SRCDIR)
+
+# Target to generate docx from md
+%.docx:
+	@# Convert img tags to markdown syntax for pandoc
+	sed -r 's!<img[^>]* src="([^"]+)"[^>]*>!\![](\1)!g' "$(SRCDIR)$(addsuffix .md,$(basename $@))" | pandoc -t docx -f gfm --resource-path=$(SRCDIR) --toc=true -o "$(call sanitize,$@)" -
+
+# Target to update the wiki repository
+update: $(SRCDIR)
+	git -C $(SRCDIR) pull
+
+# Main target to update the repo and then generate the docx files
+all: update
+	${MAKE} $(DOCX)
+
+# Cleanup target
+clean:
+	rm -rf *.docx $(SRCDIR)
+
+.PHONY: update all clean
+

Review Comment:
   While I like the idea of keeping related items together, as you've described, I have a couple of concerns:
   
   1. Updates/changes to things like this Makefile won't be subject to peer review as they are in the main project repo.
   
   2. Things are kind of hidden unless you explicitly clone the .wiki repo to discover the additional "hidden" files.
   
   I have a target to make .docx, but I can create others for HTML, PDF, etc. if that would be useful.  I just needed the .docx so the documentation can be available on air-gapped networks.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@daffodil.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org