Skip to content

Commit

Permalink
feat(scripts): add manuscript template
Browse files Browse the repository at this point in the history
Signed-off-by: Cameron Smith <cameron.ray.smith@gmail.com>
  • Loading branch information
cameronraysmith committed Mar 4, 2024
1 parent 75f6431 commit ce65847
Show file tree
Hide file tree
Showing 5 changed files with 511 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scripts/examples/manuscript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
_extensions/
.jupyter_cache/
index_files/
sn-*.bst
sn-*.cls
index.*
!index.qmd
63 changes: 63 additions & 0 deletions scripts/examples/manuscript/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
.DEFAULT_GOAL := help

ENV_PREFIX ?= ./
ENV_FILE := $(wildcard $(ENV_PREFIX)/.env)

ifeq ($(strip $(ENV_FILE)),)
$(info $(ENV_PREFIX)/.env file not found, skipping inclusion)
else
include $(ENV_PREFIX)/.env
export
endif

GIT_SHA_SHORT = $(shell git rev-parse --short HEAD)
GIT_REF = $(shell git rev-parse --abbrev-ref HEAD)

#-------
##@ help
#-------

# based on "https://gist.github.com/prwhite/8168133?permalink_comment_id=4260260#gistcomment-4260260"
help: ## Display this help. (Default)
@grep -hE '^(##@|[A-Za-z0-9_ \-]*?:.*##).*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; /^##@/ {print "\n" substr($$0, 5)} /^[A-Za-z0-9_ \-]*?:.*##/ {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

help-sort: ## Display alphabetized version of help (no section headings).
@grep -hE '^[A-Za-z0-9_ \-]*?:.*##.*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; /^[A-Za-z0-9_ \-]*?:.*##/ {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

HELP_TARGETS_PATTERN ?= test
help-targets: ## Print commands for all targets matching a given pattern. eval "$(make help-targets HELP_TARGETS_PATTERN=test | sed 's/\x1b\[[0-9;]*m//g')"
@make help-sort | awk '{print $$1}' | grep '$(HELP_TARGETS_PATTERN)' | xargs -I {} printf "printf '___\n\n{}:\n\n'\nmake -n {}\nprintf '\n'\n"


#-----------------
##@ install extensions
#-----------------

install-extensions: ## Install quarto extensions
quarto add cameronraysmith/nature@citeproc
cp _extensions/cameronraysmith/nature/csl/springer-basic-brackets-no-et-al.csl bibstyle.csl

#-----------------
##@ render article
#-----------------

DOCUMENT_NAME ?= index

render-latex: ## Render pdf format via LaTeX
quarto render $(DOCUMENT_NAME).qmd --to nature-pdf

render: ## Render all article formats including docx, html, ipynb, pdf, and tex
quarto render $(DOCUMENT_NAME).qmd --to all

render-refresh: ## (EXAMPLE) Render with parameter specification and cache refresh
quarto render index.qmd --to all -P TEST_MODE:False --cache-refresh

clean: ## Clean compilation artifacts
rm sn-*.{bst,cls} || true

clean-all: ## Clean all files including output files
clean-all: clean
rm $(DOCUMENT_NAME).{docx,html,ipynb,pdf,tex} || true
rm -r $(DOCUMENT_NAME)_files/
184 changes: 184 additions & 0 deletions scripts/examples/manuscript/bibstyle.csl
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only" default-locale="en-US">
<info>
<title>Springer - Basic (numeric, brackets, no "et al.")</title>
<id>http://www.zotero.org/styles/springer-basic-brackets-no-et-al</id>
<link href="http://www.zotero.org/styles/springer-basic-brackets-no-et-al" rel="self"/>
<link href="http://www.zotero.org/styles/springer-basic-author-date" rel="template"/>
<link href="http://www.springer.com/cda/content/document/cda_downloaddocument/instruct-authors-e.pdf" rel="documentation"/>
<link href="http://www.springer.com/cda/content/document/cda_downloaddocument/manuscript-guidelines-1.0.pdf" rel="documentation"/>
<!-- This style corresponds to 'Springer Basic' in the pdf document 'Key Style Points' at this url -->
<link href="http://www.springer.com/cda/content/document/cda_downloaddocument/Key_Style_Points_1.0.pdf" rel="documentation"/>
<author>
<name>Charles Parnot</name>
<email>charles.parnot@gmail.com</email>
<uri>http://twitter.com/cparnot</uri>
</author>
<category citation-format="numeric"/>
<category field="generic-base"/>
<summary>Springer Numbered Style for the disciplines Medicine, Biomedicine, Life Sciences, Chemistry, Geosciences, Computer Science, Engineering, Economics. This style is based on Harvard style and recommendations of the Council of Biology Editors.</summary>
<updated>2022-02-24T13:06:32+00:00</updated>
<rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
</info>
<macro name="author">
<names variable="author">
<name sort-separator=" " initialize-with="" name-as-sort-order="all" delimiter=", " delimiter-precedes-last="always"/>
<!--<et-al strip-periods="true"/> -->
<substitute>
<names variable="editor"/>
<names variable="translator"/>
</substitute>
</names>
</macro>
<macro name="edition">
<choose>
<if is-numeric="edition">
<group delimiter=" ">
<number variable="edition" form="ordinal"/>
<text term="edition" form="short" strip-periods="true"/>
</group>
</if>
<else>
<text variable="edition"/>
</else>
</choose>
</macro>
<macro name="title">
<choose>
<if type="book">
<group delimiter=", ">
<text variable="title"/>
<text macro="edition"/>
</group>
</if>
<else>
<text variable="title"/>
</else>
</choose>
</macro>
<macro name="year-parenth">
<date prefix="(" suffix=")" variable="issued">
<date-part name="year"/>
</date>
</macro>
<citation collapse="citation-number">
<sort>
<key variable="citation-number"/>
</sort>
<layout prefix="[" suffix="]" delimiter=", ">
<text variable="citation-number"/>
</layout>
</citation>
<bibliography second-field-align="flush">
<layout>
<text variable="citation-number" suffix=". "/>
<group delimiter=" ">
<text macro="author"/>
<text macro="year-parenth"/>
<text macro="title"/>
</group>
<choose>
<!-- Book chapter
Brown B, Aaron M (2001) The politics of nature.
In: Smith J (ed) The rise of modern genomics, 3rd edn.
Wiley, New York, pp 230-257 -->
<if type="chapter paper-conference" match="any">
<group delimiter=" " prefix=". ">
<text term="in" text-case="capitalize-first" suffix=":"/>
<names variable="editor">
<name sort-separator=" " initialize-with="" name-as-sort-order="all" delimiter=", " delimiter-precedes-last="always"/>
<label form="short" strip-periods="true" prefix=" (" suffix=")"/>
</names>
<group delimiter=", ">
<text variable="container-title"/>
<text macro="edition"/>
</group>
</group>
<group prefix=". " delimiter=", ">
<text variable="publisher"/>
<text variable="publisher-place"/>
<group delimiter=" ">
<label variable="page" form="short" strip-periods="true"/>
<text variable="page"/>
</group>
</group>
</if>
<else-if type="article-journal">
<choose>
<if variable="page volume" match="any">
<!-- Journal article
Gamelin FX, Baquet G, Berthoin S, Thevenet D, Nourry C, Nottin S, Bosquet L (2009)
Effect of high intensity intermittent training on heart rate variability in prepubescent children.
Eur J Appl Physiol 105:731-738. doi: 10.1007/s00421-008-0955-8
Ideally, the names of all authors should be provided, but the usage of "et al"
in long author lists will also be accepted:
Smith J, Jones M Jr, Houghton L et al (1999)
Future of health insurance. N Engl J Med 965:325-329 -->
<group prefix=". ">
<group delimiter=" ">
<text variable="container-title" form="short" strip-periods="true"/>
<group delimiter=":">
<text variable="volume" suffix=":"/>
<text variable="page"/>
</group>
</group>
<text prefix=". https://doi.org/" variable="DOI"/>
</group>
</if>
<else>
<!-- Article by DOI
Slifka MK, Whitton JL (2000) Clinical implications of dysregulated cytokine production.
J Mol Med. doi:10.1007/s001090000086 -->
<group prefix=". " delimiter=". ">
<text variable="container-title" form="short" strip-periods="true"/>
<text prefix="https://doi.org/" variable="DOI"/>
</group>
</else>
</choose>
</else-if>
<else-if type="bill book graphic legal_case legislation motion_picture report song" match="any">
<!-- Book
South J, Blass B (2001) The future of modern genomics. Blackwell, London -->
<group prefix=". " delimiter=", ">
<text variable="publisher"/>
<text variable="publisher-place"/>
</group>
</else-if>
<else-if type="webpage post-weblog" match="any">
<!-- Online document
Doe J (1999) Title of subordinate document. In: The dictionary of substances and their effects.
Royal Society of Chemistry. Available via DIALOG.
http://www.rsc.org/dose/title of subordinate document. Accessed 15 Jan 1999
Unfortunately, "Royal Society of Chemistry. Available via DIALOG." cannot seem to be mapped here -->
<group prefix=". " delimiter=". ">
<text prefix="In: " variable="container-title" form="short"/>
<text variable="URL"/>
<date variable="accessed">
<date-part prefix="Accessed " name="day" suffix=" "/>
<date-part name="month" form="short" suffix=" " strip-periods="true"/>
<date-part name="year"/>
</date>
</group>
</else-if>
<else-if type="thesis">
<!-- Dissertation
Trent JW (1975) Experimental acute renal failure. Dissertation, University of California -->
<group prefix=". " delimiter=", ">
<text variable="genre" text-case="capitalize-first"/>
<text variable="publisher"/>
</group>
</else-if>
<else>
<!-- None of the provided formats need to add manually (some data provided) -->
<group prefix=". " delimiter=" ">
<text variable="container-title" form="short"/>
<group delimiter=":">
<text variable="volume"/>
<text variable="page"/>
</group>
</group>
</else>
</choose>
</layout>
</bibliography>
</style>
Loading

0 comments on commit ce65847

Please sign in to comment.