mirror of
https://github.com/kjanat/articulate-parser.git
synced 2026-10-13 00:55:27 +02:00
chore: adopt remote dprint config, tidy examples
Extend dprint from a shared remote config and add the prettier and exec plugins, formatting TOML via a new tombi.toml instead of golangci-lint fmt. Taskfile.yml, scripts/build.sh, and html_styles.css pick up the resulting reformat. Exporter examples now write to a temp dir and clean up after themselves instead of leaving output.md/.docx/.html in the repo. Drop the stray internal/exporters/output.docx and ignore internal/exporters/output.* going forward.
This commit is contained in:
+13
-37
@@ -1,43 +1,19 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://dprint.dev/schemas/v0.json",
|
"$schema": "https://dprint.dev/schemas/v0.json",
|
||||||
|
"extends": "https://github.com/kjanat/kjanat/raw/8cb7b67/configs/dprint.remote.json",
|
||||||
"useTabs": true,
|
"excludes": ["**/node_modules", "**/.venv", "**/bun.lock*"],
|
||||||
|
"plugins": [
|
||||||
"typescript": {},
|
"npm:@dprint/prettier@0.70.0/plugin.json@97c0dccf54ed5b7343e7a3f6418e77bd80afcd2b74beed3a632689d47e392ddc",
|
||||||
"json": {},
|
"npm:@dprint/exec@0.7.3/plugin.json@704701df449dd7e942a71144773778ac529d68c2e4657bfc236d393b898b9a67",
|
||||||
"markdown": {},
|
],
|
||||||
"toml": {},
|
"markdown": { "associations": ["!README.md"] },
|
||||||
"dockerfile": {},
|
"prettier": { "associations": ["README.md"], "useTabs": false },
|
||||||
"oxc": {},
|
|
||||||
"ruff": {},
|
|
||||||
"jupyter": {},
|
|
||||||
"malva": {},
|
|
||||||
"markup": {},
|
|
||||||
"yaml": {},
|
|
||||||
"exec": {
|
"exec": {
|
||||||
"cwd": "${configDir}",
|
"cwd": "${configDir}",
|
||||||
"commands": [
|
"commands": [{
|
||||||
{
|
"command": "bunx tombi format - --stdin-filename {{file_path}}",
|
||||||
"command": "golangci-lint fmt --config .golangci.yml --color never --stdin {{file_path}}",
|
"exts": ["toml"],
|
||||||
"exts": ["go"],
|
"cacheKeyFiles": ["tombi.toml"],
|
||||||
"cacheKeyFiles": [".golangci.yml"],
|
}],
|
||||||
"stdin": true,
|
|
||||||
},
|
},
|
||||||
],
|
|
||||||
},
|
|
||||||
"excludes": ["**/node_modules", "**/*-lock.json"],
|
|
||||||
"plugins": [
|
|
||||||
"https://plugins.dprint.dev/typescript-0.95.13.wasm",
|
|
||||||
"https://plugins.dprint.dev/json-0.21.1.wasm",
|
|
||||||
"https://plugins.dprint.dev/markdown-0.20.0.wasm",
|
|
||||||
"https://plugins.dprint.dev/toml-0.7.0.wasm",
|
|
||||||
"https://plugins.dprint.dev/dockerfile-0.3.3.wasm",
|
|
||||||
"https://plugins.dprint.dev/oxc-0.1.0.wasm",
|
|
||||||
"https://plugins.dprint.dev/ruff-0.6.11.wasm",
|
|
||||||
"https://plugins.dprint.dev/jupyter-0.2.1.wasm",
|
|
||||||
"https://plugins.dprint.dev/g-plane/malva-v0.15.1.wasm",
|
|
||||||
"https://plugins.dprint.dev/g-plane/markup_fmt-v0.25.3.wasm",
|
|
||||||
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.1.wasm",
|
|
||||||
"https://plugins.dprint.dev/exec-0.6.0.json@a054130d458f124f9b5c91484833828950723a5af3f8ff2bd1523bd47b83b364",
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ output/
|
|||||||
outputs/
|
outputs/
|
||||||
articulate-sample.json
|
articulate-sample.json
|
||||||
test-output.*
|
test-output.*
|
||||||
|
# Example test exports (defensive; tests now write to a temp dir)
|
||||||
|
internal/exporters/output.*
|
||||||
go-os-arch-matrix.csv
|
go-os-arch-matrix.csv
|
||||||
test_godocx.go
|
test_godocx.go
|
||||||
test_input.json
|
test_input.json
|
||||||
|
|||||||
@@ -4,12 +4,25 @@ package exporters_test
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/kjanat/articulate-parser/internal/exporters"
|
"github.com/kjanat/articulate-parser/internal/exporters"
|
||||||
"github.com/kjanat/articulate-parser/internal/models"
|
"github.com/kjanat/articulate-parser/internal/models"
|
||||||
"github.com/kjanat/articulate-parser/internal/services"
|
"github.com/kjanat/articulate-parser/internal/services"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// tempOutput returns a path inside a fresh temp dir plus a cleanup func, so
|
||||||
|
// example exports don't pollute the package source tree. Example functions
|
||||||
|
// can't take *testing.T, so t.TempDir is unavailable here.
|
||||||
|
func tempOutput(name string) (path string, cleanup func()) {
|
||||||
|
dir, err := os.MkdirTemp("", "exporters-example-*")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
return filepath.Join(dir, name), func() { _ = os.RemoveAll(dir) }
|
||||||
|
}
|
||||||
|
|
||||||
// ExampleNewFactory demonstrates creating an exporter factory.
|
// ExampleNewFactory demonstrates creating an exporter factory.
|
||||||
func ExampleNewFactory() {
|
func ExampleNewFactory() {
|
||||||
htmlCleaner := services.NewHTMLCleaner()
|
htmlCleaner := services.NewHTMLCleaner()
|
||||||
@@ -69,7 +82,9 @@ func ExampleMarkdownExporter_Export() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Export to markdown file
|
// Export to markdown file
|
||||||
err := exporter.Export(course, "output.md")
|
out, cleanup := tempOutput("output.md")
|
||||||
|
defer cleanup()
|
||||||
|
err := exporter.Export(course, out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -91,7 +106,9 @@ func ExampleDocxExporter_Export() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Export to Word document
|
// Export to Word document
|
||||||
err := exporter.Export(course, "output.docx")
|
out, cleanup := tempOutput("output.docx")
|
||||||
|
defer cleanup()
|
||||||
|
err := exporter.Export(course, out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -121,7 +138,9 @@ func ExampleHTMLExporter_Export() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Export to HTML file
|
// Export to HTML file
|
||||||
err := exporter.Export(course, "output.html")
|
out, cleanup := tempOutput("output.html")
|
||||||
|
defer cleanup()
|
||||||
|
err := exporter.Export(course, out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
body {
|
body {
|
||||||
font-family:
|
font-family:
|
||||||
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
|
-apple-system,
|
||||||
Cantarell, sans-serif;
|
BlinkMacSystemFont,
|
||||||
|
"Segoe UI",
|
||||||
|
Roboto,
|
||||||
|
Oxygen,
|
||||||
|
Ubuntu,
|
||||||
|
Cantarell,
|
||||||
|
sans-serif;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
color: #333;
|
color: #333;
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
|
|||||||
Binary file not shown.
+49
@@ -0,0 +1,49 @@
|
|||||||
|
# :schema tombi://www.schemastore.org/tombi.json
|
||||||
|
# :tombi toml-version = "v1.1.0"
|
||||||
|
|
||||||
|
toml-version = "v1.1.0"
|
||||||
|
|
||||||
|
[files]
|
||||||
|
include = ["**/*.toml", "**/.*.toml"]
|
||||||
|
exclude = ["**/fixtures"]
|
||||||
|
|
||||||
|
[format]
|
||||||
|
[format.rules]
|
||||||
|
array-bracket-space-width = 0
|
||||||
|
array-comma-space-width = 1
|
||||||
|
date-time-delimiter = "T"
|
||||||
|
indent-style = "space"
|
||||||
|
indent-sub-tables = false
|
||||||
|
indent-table-key-value-pairs = false
|
||||||
|
indent-width = 2
|
||||||
|
inline-table-brace-space-width = 1
|
||||||
|
inline-table-comma-space-width = 1
|
||||||
|
key-value-equals-sign-alignment = true
|
||||||
|
key-value-equals-sign-space-width = 1
|
||||||
|
line-ending = "lf"
|
||||||
|
line-width = 140
|
||||||
|
string-quote-style = "double"
|
||||||
|
trailing-comment-alignment = true
|
||||||
|
trailing-comment-space-width = 2
|
||||||
|
|
||||||
|
[lint]
|
||||||
|
[lint.rules]
|
||||||
|
dotted-keys-out-of-order = "warn"
|
||||||
|
key-empty = "warn"
|
||||||
|
tables-out-of-order = "error"
|
||||||
|
|
||||||
|
[lsp]
|
||||||
|
code-action.enabled = true
|
||||||
|
completion.enabled = true
|
||||||
|
diagnostic.enabled = true
|
||||||
|
document-link.enabled = true
|
||||||
|
formatting.enabled = true
|
||||||
|
goto-declaration.enabled = true
|
||||||
|
goto-definition.enabled = true
|
||||||
|
goto-type-definition.enabled = true
|
||||||
|
hover.enabled = true
|
||||||
|
workspace-diagnostic.enabled = true
|
||||||
|
|
||||||
|
[schema]
|
||||||
|
enabled = true
|
||||||
|
strict = true
|
||||||
Reference in New Issue
Block a user