1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-27 00:58:36 +00:00

Refactor doc component, update doc docs.

This commit is contained in:
Brenden Matthews 2022-09-30 11:31:40 -05:00 committed by Brenden Matthews
parent 9ce453e148
commit a7696b1ca6
9 changed files with 92 additions and 129 deletions

View File

@ -10,6 +10,13 @@ The `desc` field within the docs can be formatted with markdown, however _do
not_ include headings within the `desc` fields, as it will mess up the man page
output. In markdown, headings begin with `#`.
The supported documentation fields are:
* `name`: the name of the thing
* `desc`: a markdown-formatted description of the thing
* `args`: optional list of arguments
* `default`: an optional default value, if applicable
## Updating docs
The man page is based on [`man.md.j2`](man.md.j2) which is a Jinja2 template.

View File

@ -2,6 +2,13 @@
#
# The `desc` field can be formatted with markdown, but please do not include
# headings (lines beginning with `#`) in the `desc` field.
#
# The supported fields are:
#
# * `name`: the name of the thing
# * `desc`: a markdown-formatted description of the thing
# * `args`: optional list of arguments
# * `default`: an optional default value, if applicable
---
- name: alignment
desc: |-

View File

@ -2,6 +2,13 @@
#
# The `desc` field can be formatted with markdown, but please do not include
# headings (lines beginning with `#`) in the `desc` field.
#
# The supported fields are:
#
# * `name`: the name of the thing
# * `desc`: a markdown-formatted description of the thing
# * `args`: optional list of arguments
# * `default`: an optional default value, if applicable
---
- name: cairo_font_extents_t:create()
desc: |-

View File

@ -2,6 +2,13 @@
#
# The `desc` field can be formatted with markdown, but please do not include
# headings (lines beginning with `#`) in the `desc` field.
#
# The supported fields are:
#
# * `name`: the name of the thing
# * `desc`: a markdown-formatted description of the thing
# * `args`: optional list of arguments
# * `default`: an optional default value, if applicable
---
- name: acpiacadapter
desc: |-

42
web/components/Docs.tsx Normal file
View File

@ -0,0 +1,42 @@
import { Doc } from '../utils/doc-utils'
import { Link } from 'react-feather'
export interface DocsProps {
docs: Doc[]
}
export default function Docs({ docs }: DocsProps) {
return (
<>
{docs.map((doc) => (
<div
id={doc.name}
key={doc.name}
className="scroll-mt-16 target:bg-rose-300 target:dark:bg-rose-900 hover:bg-slate-100 dark:hover:bg-slate-800 my-4"
>
<div className="flex">
<div className="p-2">
<a href={`#${doc.name}`}>
<Link size={16} />
</a>
</div>
<div className="flex-col p-1">
<code className="text-lg p-1 bg-fuchsia-200 dark:bg-fuchsia-900 font-bold">
{doc.name}
</code>
<div
className="py-2"
dangerouslySetInnerHTML={{ __html: doc.desc }}
/>
{doc.default && (
<div>
Default: <code>{doc.default}</code>
</div>
)}
</div>
</div>
</div>
))}
</>
)
}

View File

@ -1,10 +1,10 @@
import Layout from '../components/Layout'
import SEO from '../components/SEO'
import { ConfigSetting, getConfigSettings } from '../utils/doc-utils'
import { Link } from 'react-feather'
import { Doc, getConfigSettings } from '../utils/doc-utils'
import Docs from '../components/Docs'
export interface ConfigSettingsProps {
config_settings: ConfigSetting[]
config_settings: Doc[]
}
export default function ConfigSettings(props: ConfigSettingsProps) {
@ -19,36 +19,7 @@ export default function ConfigSettings(props: ConfigSettingsProps) {
<h1 className="text-2xl">Configuration settings</h1>
<p></p>
</div>
<div>
{props.config_settings.map((cs) => (
<div
id={cs.name}
key={cs.name}
className="scroll-mt-16 target:bg-rose-300 target:dark:bg-rose-900 hover:bg-slate-100 dark:hover:bg-slate-800 my-4"
>
<div className="flex">
<div className="p-2">
<a href={`#${cs.name}`}>
<Link size={16} />
</a>
</div>
<div className="flex-col p-1">
<code className="text-lg p-1 bg-fuchsia-200 dark:bg-fuchsia-900 font-bold">
{cs.name}
</code>
<div
className="py-2"
dangerouslySetInnerHTML={{ __html: cs.desc }}
/>
<div className="">
Default:{' '}
{cs.default ? <code>{cs.default}</code> : <em>n/a</em>}
</div>
</div>
</div>
</div>
))}
</div>
<Docs docs={props.config_settings} />
</main>
</Layout>
)

View File

@ -1,10 +1,10 @@
import Layout from '../components/Layout'
import SEO from '../components/SEO'
import { getLua, LuaDoc } from '../utils/doc-utils'
import { Link } from 'react-feather'
import { getLua, Doc } from '../utils/doc-utils'
import Docs from '../components/Docs'
export interface LuaProps {
lua: LuaDoc[]
lua: Doc[]
}
export default function Lua(props: LuaProps) {
@ -15,32 +15,7 @@ export default function Lua(props: LuaProps) {
<div>
<h1 className="text-2xl">Lua API</h1>
</div>
<div>
{props.lua.map((cs) => (
<div
id={cs.name}
key={cs.name}
className="scroll-mt-16 target:bg-rose-300 target:dark:bg-rose-900 hover:bg-slate-100 dark:hover:bg-slate-800 my-4"
>
<div className="flex">
<div className="p-2">
<a href={`#${cs.name}`}>
<Link size={16} />
</a>
</div>
<div className="flex-col p-1">
<code className="text-lg p-1 bg-fuchsia-200 dark:bg-fuchsia-900 font-bold">
{cs.name}
</code>
<div
className="py-2"
dangerouslySetInnerHTML={{ __html: cs.desc }}
/>
</div>
</div>
</div>
))}
</div>
<Docs docs={props.lua} />
</main>
</Layout>
)

View File

@ -1,10 +1,10 @@
import Layout from '../components/Layout'
import SEO from '../components/SEO'
import { getVariables, Variable } from '../utils/doc-utils'
import { Link } from 'react-feather'
import { getVariables, Doc } from '../utils/doc-utils'
import Docs from '../components/Docs'
export interface VariablesProps {
variables: Variable[]
variables: Doc[]
}
export default function Variables(props: VariablesProps) {
@ -18,36 +18,7 @@ export default function Variables(props: VariablesProps) {
<div>
<h1 className="text-2xl">Variables</h1>
</div>
<div>
{props.variables.map((cs) => (
<div
id={cs.name}
key={cs.name}
className="scroll-mt-16 target:bg-rose-300 target:dark:bg-rose-900 hover:bg-slate-100 dark:hover:bg-slate-800 my-4"
>
<div className="flex">
<div className="p-2">
<a href={`#${cs.name}`}>
<Link size={16} />
</a>
</div>
<div className="flex-col p-1">
<code className="text-lg p-1 bg-fuchsia-200 dark:bg-fuchsia-900 font-bold">
{cs.name}
</code>
<div
className="py-2"
dangerouslySetInnerHTML={{ __html: cs.desc }}
/>
<div className="">
Default:{' '}
{cs.default ? <code>{cs.default}</code> : <em>n/a</em>}
</div>
</div>
</div>
</div>
))}
</div>
<Docs docs={props.variables} />
</main>
</Layout>
)

View File

@ -9,57 +9,33 @@ import rehypeStringify from 'rehype-stringify'
const DOC_PATH = path.join(process.cwd(), '..', 'doc')
export interface ConfigSetting {
export interface Doc {
name: string
desc: string
default: string | undefined
args: string[]
}
export function getConfigSettings(): ConfigSetting[] {
function getDocumentation(source: string): Doc[] {
const configSettingsFile = fs.readFileSync(
path.join(DOC_PATH, 'config_settings.yaml'),
path.join(DOC_PATH, source),
'utf-8'
)
const parsed = yaml.load(configSettingsFile.toString()) as ConfigSetting[]
const parsed = yaml.load(configSettingsFile.toString()) as Doc[]
const docs = parsed.map((c) => ({ ...c, desc: processMarkdown(c.desc) }))
return docs
}
export interface Variable {
name: string
desc: string
default: string | undefined
args: string[]
export function getConfigSettings(): Doc[] {
return getDocumentation('config_settings.yaml')
}
export function getVariables(): Variable[] {
const variablesFile = fs.readFileSync(
path.join(DOC_PATH, 'variables.yaml'),
'utf-8'
)
const parsed = yaml.load(variablesFile.toString()) as Variable[]
const docs = parsed.map((c) => ({ ...c, desc: processMarkdown(c.desc) }))
return docs
export function getVariables(): Doc[] {
return getDocumentation('variables.yaml')
}
export interface LuaDoc {
name: string
desc: string
args: string[]
}
export function getLua(): LuaDoc[] {
const variablesFile = fs.readFileSync(
path.join(DOC_PATH, 'lua.yaml'),
'utf-8'
)
const parsed = yaml.load(variablesFile.toString()) as LuaDoc[]
const docs = parsed.map((c) => ({ ...c, desc: processMarkdown(c.desc) }))
return docs
export function getLua(): Doc[] {
return getDocumentation('lua.yaml')
}
function processMarkdown(input: string): string {