feat(gen-docs): add Hugo partials docs generation (#809)

* feat(gen-docs): add documentation generation package with SassDoc and TypeDoc support

Add new `@hugo-fixit/gen-docs` package that parses Hugo config (hugo.toml) and generates
documentation. Includes SassDoc annotations for SCSS variables and mixins, TypeDoc config
for TypeScript source docs, and a `.sassdocrc` configuration file.

* docs(readme): add browsers support section

* feat(gen-docs): add Hugo partials docs generation and fix config empty sections

- Add partial-parser.ts: parses Hugo partial comment blocks (@param/@return/@example)
- Add partials.ts renderer: generates grouped Markdown with param tables
- Add `partials` subcommand with -t/-o options for template injection
- Fix config-parser: empty TOML sections (library.js/library.css) now retain descriptions
- Fix config-parser: correctly distinguish section-level vs key-level comments
- Update README with partials subcommand documentation
This commit is contained in:
Cell
2026-07-21 12:19:07 +08:00
committed by GitHub
parent e07eefd506
commit 2c0b48370b
40 changed files with 2317 additions and 955 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
Loads the main stylesheet (every page) and conditionally loads
page-specific CSS based on .Kind, .Layout, and .RelPermalink.
Called from: base/head/index.html
Called from: `base/head/index.html`
*/ -}}
{{- $scssVars := partialCached "function/scss-vars.html" . -}}
@@ -24,7 +24,7 @@
@example
// Practical usage in templates
{{- $siteParams := partial "function/camel-case-keys.html" .Site.Params }}
{{- $siteParams := partial "function/camel-case-keys.html" .Site.Params -}}
*/ -}}
{{- $input := . | default dict -}}
{{- $output := dict -}}
+3 -1
View File
@@ -5,7 +5,9 @@
@param {String} . - The snake_case string
@return {String} The camelCase string
@example "max_shown_lines" -> "maxShownLines"
@example
// "max_shown_lines" -> "maxShownLines"
{{- partial "function/camel-case.html" "max_shown_lines" -}}
*/ -}}
{{- $parts := split . "_" -}}
{{- $result := index $parts 0 -}}
+5 -2
View File
@@ -1,5 +1,8 @@
{{- /* Escape url special characters to query format, e.g: `#` -> `%23` */ -}}
{{- /* https://github.com/hugo-fixit/FixIt/issues/245 */ -}}
{{- /*
Escape URL special characters to query format, e.g: `#` -> `%23`
See: https://github.com/hugo-fixit/FixIt/issues/245
*/ -}}
{{- $content := . -}}
{{- $content = replace $content "#" "%23" -}}
+2 -1
View File
@@ -21,8 +21,9 @@
@example
{{- $cover := dict "Page" . | partial "function/get-cover.html" -}}
{{- with $cover.URL }}<img src="{{ . }}">{{ end -}}
{{- with $cover.URL -}}<img src="{{ . }}">{{- end -}}
@example
{{- $cover := dict "Page" . "Preview" true | partial "function/get-cover.html" -}}
{{- dict "Src" $cover.URL "Resources" .Resources "Matches" $cover.Matches | partial "plugin/image.html" -}}
*/ -}}
@@ -1,7 +1,12 @@
{{- /*
Example:
{{- $suffixList := slice ".jpeg" ".jpg" ".png" ".gif" ".bmp" ".tif" ".tiff" ".webp" ".avif" ".svg" -}}
{{- $suffixValid := (dict "Path" .Path "Suffixes" $suffixList | partial "function/suffix-validation.html") -}}
{{- /*
Validate if the given path has a valid suffix.
@param Path string The path to validate.
@param Suffixes []string The list of valid suffixes.
@return bool True if the path has a valid suffix, false otherwise.
@example
{{- $suffixList := slice ".jpeg" ".jpg" ".png" ".gif" ".bmp" ".tif" ".tiff" ".webp" ".avif" ".svg" -}}
{{- $suffixValid := (dict "Path" .Path "Suffixes" $suffixList | partial "function/suffix-validation.html") -}}
*/ -}}
{{- $url := urls.Parse .Path -}}
{{- $path := path.Clean ((printf "%v%v" $url.Host $url.Path) | lower) -}}
+2 -2
View File
@@ -1,9 +1,9 @@
{{- /*
Icon renderer for Font Awesome classes and SVG sources.
- Renders <i> element when Class is provided.
- Renders `<i>` element when `.Class` is provided.
- Resolves local SVG resources or external SVG URL fallback.
- Supports Simple Icons shorthand by icon name.
@param {String} [.Class] - Icon class name for <i>
@param {String} [.Class] - Icon class name for `<i>`
@param {String} [.Src] - SVG source path or URL
@param {String} [.Simpleicons] - Simple-icons icon name
@param {String} [.Prefix] - Custom prefix for simple-icons source path
+1 -1
View File
@@ -1,6 +1,6 @@
{{- /*
Social profile link helper.
- Builds destination from explicit Url or from Prefix/Template/Id.
- Builds destination from explicit URL or from Prefix/Template/Id.
- Delegates final rendering to plugin/link.html with rel=me.
@param {String} [.Url] - Explicit target URL
@param {String} [.Template] - URL template containing one %%v placeholder
+1 -1
View File
@@ -1,6 +1,6 @@
{{- /*
Stylesheet tag renderer.
- Accepts direct <link> HTML, a pre-built resource, or builds from source path.
- Accepts direct `<link>` HTML, a pre-built resource, or builds from source path.
- Supports template execution, optional toCSS, minify/fingerprint, and preload mode.
@param {String} [.Source] - Stylesheet URL/path; if starts with "<link" it's treated as raw HTML
@param {resource.Resource} [.Resource] - Pre-built resource (skips build pipeline)