Skip to content

Commit 3d527e3

Browse files
authored
feat: Add option for setting date pattern (#60)
* feat: Add option for setting date pattern * fix: action.yaml fields mix-up
1 parent d4026d0 commit 3d527e3

File tree

6 files changed

+21
-2
lines changed

6 files changed

+21
-2
lines changed

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ jobs:
8585
version: "NVIM v0.8.0" # Vim version number
8686
toc: true # Table of contents
8787
description: "" # Project description used in title (if empty, uses neovim version and current date)
88+
titledatepattern: "%Y %B %d" # Pattern for the date that used in the title
8889
demojify: false # Strip emojis from the vimdoc
8990
dedupsubheadings: true # Add heading to subheading anchor links to ensure that subheadings are unique
9091
treesitter: true # Use treesitter for highlighting codeblocks
@@ -185,6 +186,7 @@ Arguments:
185186
--toc: 'true' if the output should include a table of contents, 'false' otherwise
186187
--description: a project description used in title (if empty, uses neovim version and current date)
187188
--dedup-subheadings: 'true' if duplicate subheadings should be removed, 'false' otherwise
189+
--title-date-pattern: '%Y %B %d' a pattern for the date that used in the title
188190
--demojify: 'false' if emojis should not be removed, 'true' otherwise
189191
--treesitter: 'true' if the project uses Tree-sitter syntax highlighting, 'false' otherwise
190192
--ignore-rawblocks: 'true' if the project should ignore HTML raw blocks, 'false' otherwise

Diff for: action.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ inputs:
2424
description: "Project description used in title (if empty, uses neovim version and current date)"
2525
required: false
2626
default: ""
27+
titledatepattern:
28+
description: "Pattern for the date that used in the title (if empty, uses '%Y %B %d')"
29+
required: false
30+
default: "%Y %B %d"
2731
demojify:
2832
description: "Strip emojis from the vimdoc"
2933
required: false
@@ -70,6 +74,8 @@ runs:
7074
- ${{ inputs.toc }}
7175
- --description
7276
- ${{ inputs.description }}
77+
- --title-date-pattern
78+
- ${{ inputs.titledatepattern }}
7379
- --dedup-subheadings
7480
- ${{ inputs.dedupsubheadings }}
7581
- --demojify

Diff for: doc/panvimdoc.txt

+2
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ Then add the following to `./.github/workflows/panvimdoc.yml`:
137137
version: "NVIM v0.8.0" # Vim version number
138138
toc: true # Table of contents
139139
description: "" # Project description used in title (if empty, uses neovim version and current date)
140+
titledatepattern: "%Y %B %d" # Pattern for the date that used in the title
140141
demojify: false # Strip emojis from the vimdoc
141142
dedupsubheadings: true # Add heading to subheading anchor links to ensure that subheadings are unique
142143
treesitter: true # Use treesitter for highlighting codeblocks
@@ -234,6 +235,7 @@ output writer.
234235
--vim-version: the version of Vim that the project is compatible with
235236
--toc: 'true' if the output should include a table of contents, 'false' otherwise
236237
--description: a project description used in title (if empty, uses neovim version and current date)
238+
--title-date-pattern: '%Y %B %d' a pattern for the date that used in the title
237239
--dedup-subheadings: 'true' if duplicate subheadings should be removed, 'false' otherwise
238240
--demojify: 'false' if emojis should not be removed, 'true' otherwise
239241
--treesitter: 'true' if the project uses Tree-sitter syntax highlighting, 'false' otherwise

Diff for: justfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
build:
2-
@./panvimdoc.sh "--project-name" "panvimdoc" "--input-file" "doc/panvimdoc.md" "--vim-version" "NVIM v0.8.0" "--toc" "true" "--description" "" "--dedup-subheadings" "true" "--demojify" "false" "--treesitter" "true" "--ignore-rawblocks" "true" "--doc-mapping" "false" "--doc-mapping-project-name" "true" --shift-heading-level-by 0 --increment-heading-level-by 0
2+
@./panvimdoc.sh "--project-name" "panvimdoc" "--input-file" "doc/panvimdoc.md" "--vim-version" "NVIM v0.8.0" "--toc" "true" "--description" "" "--title-date-pattern" "%Y %B %d" "--dedup-subheadings" "true" "--demojify" "false" "--treesitter" "true" "--ignore-rawblocks" "true" "--doc-mapping" "false" "--doc-mapping-project-name" "true" --shift-heading-level-by 0 --increment-heading-level-by 0
33

44
test:
55
julia --project -e 'using Pkg; Pkg.test()'

Diff for: panvimdoc.sh

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Arguments:
1313
--vim-version: the version of Vim that the project is compatible with
1414
--toc: 'true' if the output should include a table of contents, 'false' otherwise
1515
--description: a project description used in title (if empty, uses neovim version and current date)
16+
--title-date-pattern: '%Y %B %d' a pattern for the date that used in the title
1617
--dedup-subheadings: 'true' if duplicate subheadings should be removed, 'false' otherwise
1718
--demojify: 'false' if emojis should not be removed, 'true' otherwise
1819
--treesitter: 'true' if the project uses Tree-sitter syntax highlighting, 'false' otherwise
@@ -51,6 +52,11 @@ while [[ $# -gt 0 ]]; do
5152
shift # past argument
5253
shift # past value
5354
;;
55+
--title-date-pattern)
56+
TITLE_DATE_PATTERN="$2"
57+
shift # past argument
58+
shift # past value
59+
;;
5460
--description)
5561
DESCRIPTION="$2"
5662
shift # past argument
@@ -135,6 +141,7 @@ ARGS=(
135141
"--metadata=vimversion:${VIM_VERSION:-""}"
136142
"--metadata=toc:${TOC:-true}"
137143
"--metadata=description:${DESCRIPTION:-""}"
144+
"--metadata=titledatepattern:${TITLE_DATE_PATTERN:-"%Y %B %d"}"
138145
"--metadata=dedupsubheadings:${DEDUP_SUBHEADINGS:-true}"
139146
"--metadata=ignorerawblocks:${IGNORE_RAWBLOCKS:-true}"
140147
"--metadata=docmapping:${DOC_MAPPING:-false}"

Diff for: scripts/panvimdoc.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ local IGNORE_RAWBLOCKS = true
7373
local DOC_MAPPING = true
7474
local DOC_MAPPING_PROJECT = true
7575
local DATE = nil
76+
local TITLE_DATE_PATTERN = "%Y %B %d"
7677

7778
local CURRENT_HEADER = nil
7879
local SOFTBREAK_TO_HARDBREAK = "space"
@@ -116,7 +117,7 @@ local function renderTitle()
116117

117118
local date = DATE
118119
if date == nil then
119-
date = os.date("%Y %B %d")
120+
date = os.date(TITLE_DATE_PATTERN)
120121
end
121122
local m = "For " .. vim_version
122123
local r = "Last change: " .. date
@@ -197,6 +198,7 @@ Writer.Pandoc = function(doc, opts)
197198
DOC_MAPPING_PROJECT = doc.meta.docmappingproject
198199
HEADER_COUNT = HEADER_COUNT + doc.meta.incrementheadinglevelby
199200
DATE = doc.meta.date
201+
TITLE_DATE_PATTERN = doc.meta.titledatepattern
200202
local d = blocks(doc.blocks)
201203
local toc = renderToc()
202204
local notes = renderNotes()

0 commit comments

Comments
 (0)