add plausibleAnalytics support for koch docs[backport:1.6] (#20454)
add plausibleAnalytics to koch docs[backport:1.6]
This commit is contained in:
parent
ae050b05e9
commit
96c5586d03
3 changed files with 10 additions and 4 deletions
|
|
@ -304,6 +304,10 @@ proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef,
|
||||||
conf.configVars, filename.string,
|
conf.configVars, filename.string,
|
||||||
docgenFindFile, compilerMsgHandler)
|
docgenFindFile, compilerMsgHandler)
|
||||||
|
|
||||||
|
if conf.configVars.hasKey("doc.googleAnalytics") and
|
||||||
|
conf.configVars.hasKey("doc.plausibleAnalytics"):
|
||||||
|
doAssert false, "Either use googleAnalytics or plausibleAnalytics"
|
||||||
|
|
||||||
if conf.configVars.hasKey("doc.googleAnalytics"):
|
if conf.configVars.hasKey("doc.googleAnalytics"):
|
||||||
result.analytics = """
|
result.analytics = """
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -317,6 +321,10 @@ proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef,
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
""" % [conf.configVars.getOrDefault"doc.googleAnalytics"]
|
""" % [conf.configVars.getOrDefault"doc.googleAnalytics"]
|
||||||
|
elif conf.configVars.hasKey("doc.plausibleAnalytics"):
|
||||||
|
result.analytics = """
|
||||||
|
<script defer data-domain="$1" src="https://plausible.io/js/plausible.js"></script>
|
||||||
|
""" % [conf.configVars.getOrDefault"doc.plausibleAnalytics"]
|
||||||
else:
|
else:
|
||||||
result.analytics = ""
|
result.analytics = ""
|
||||||
|
|
||||||
|
|
|
||||||
5
koch.nim
5
koch.nim
|
|
@ -92,9 +92,6 @@ Commands for core developers:
|
||||||
tests [options] run the testsuite (run a subset of tests by
|
tests [options] run the testsuite (run a subset of tests by
|
||||||
specifying a category, e.g. `tests cat async`)
|
specifying a category, e.g. `tests cat async`)
|
||||||
temp options creates a temporary compiler for testing
|
temp options creates a temporary compiler for testing
|
||||||
Web options:
|
|
||||||
--googleAnalytics:UA-... add the given google analytics code to the docs. To
|
|
||||||
build the official docs, use UA-48159761-1
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
let kochExe* = when isMainModule: os.getAppFilename() # always correct when koch is main program, even if `koch` exe renamed e.g.: `nim c -o:koch_debug koch.nim`
|
let kochExe* = when isMainModule: os.getAppFilename() # always correct when koch is main program, even if `koch` exe renamed e.g.: `nim c -o:koch_debug koch.nim`
|
||||||
|
|
@ -679,7 +676,7 @@ when isMainModule:
|
||||||
case normalize(op.key)
|
case normalize(op.key)
|
||||||
of "boot": boot(op.cmdLineRest)
|
of "boot": boot(op.cmdLineRest)
|
||||||
of "clean": clean(op.cmdLineRest)
|
of "clean": clean(op.cmdLineRest)
|
||||||
of "doc", "docs": buildDocs(op.cmdLineRest, localDocsOnly, localDocsOut)
|
of "doc", "docs": buildDocs(op.cmdLineRest & paCode, localDocsOnly, localDocsOut)
|
||||||
of "doc0", "docs0":
|
of "doc0", "docs0":
|
||||||
# undocumented command for Araq-the-merciful:
|
# undocumented command for Araq-the-merciful:
|
||||||
buildDocs(op.cmdLineRest & gaCode)
|
buildDocs(op.cmdLineRest & gaCode)
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import "../compiler/nimpaths"
|
||||||
|
|
||||||
const
|
const
|
||||||
gaCode* = " --doc.googleAnalytics:UA-48159761-1"
|
gaCode* = " --doc.googleAnalytics:UA-48159761-1"
|
||||||
|
paCode* = " --doc.plausibleAnalytics:nim-lang.org"
|
||||||
# errormax: subsequent errors are probably consequences of 1st one; a simple
|
# errormax: subsequent errors are probably consequences of 1st one; a simple
|
||||||
# bug could cause unlimited number of errors otherwise, hard to debug in CI.
|
# bug could cause unlimited number of errors otherwise, hard to debug in CI.
|
||||||
docDefines = "-d:nimExperimentalLinenoiseExtra"
|
docDefines = "-d:nimExperimentalLinenoiseExtra"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue