How to make your own templates for codelabs in claat - google-codelab

I need to embed codelabs into an existing web site.
So, I need to change the actual HTML output (I need to get rid of etc.)
In claat's own help I see:
Note that the built-in templates of the formats are not guaranteed to be stable.
They can be found in https://github.com/googlecodelabs/tools/tree/master/claat/render.
Please avoid using default templates in production. Use your own copies.
To use a custom format, specify a local file path to a Go template file.
More info on Go templates: https://golang.org/pkg/text/template/.
Except that:
The link provided is very API-ish
The only command line option that mentiones templates is this:
-extra string
Additional arguments to pass to format templates. JSON object of string,string key values.
What do I actually need to do to pass claat a different template?

As the help message implies, use the format option. html or md are merely shortcuts to use the built-in templates.
claat export -f [template filepath] [source filepath]
Also was trying to solve this a year after it was first asked. It doesn't say explicitly, but digging into the source we can find where the format option is parsed.
https://github.com/googlecodelabs/tools/blob/main/claat/render/template.go#L166
Following that, we can specify our own html or text template file (relative or absolute path) with the -f option, instead of the default html or md format option (loading built-in templates).
These templates are parsed according to:
https://pkg.go.dev/html/template
https://pkg.go.dev/text/template
as the help message indicates.

Related

Can we change any file type using variable substitution rather than just JSON or XML

I want to change a js file and html file using release pipeline in VSTS. What I see is VSTS only allows JSON and XML config file transformation but I want to change other types(formats eg: .cs, .js, .ts, etc) of file as well.
Earlier we were using octopus deploy which has the option to transform these files.
Please let know if you know some other way to change the file in pipeline itself..
Can we change any file type using variable substitution rather than just JSON or XML
You could use Replace tokens from the Marketplace:
https://marketplace.visualstudio.com/items?itemName=qetza.replacetokens
to change other types files.
You define the desired values as variables in the Release Definition and then you add the Replace Tokens task and configure a wildcard path for all target text files in your repository where you want to replace values. The token that gets replaced has configurable prefix and postfix (default are #{ and }#).
So, the format of variable in those files are #{TestVar}#.
Check my other thread for some more details.
Update:
We do not want to use third party tools from marketplace, do we have
any way within the scope of existing microsoft tools.
I am afraid there is no such directly existing Microsoft tools to change other types files at this moment, you could develop your powershell scripts to replace file content.
Check this thread for some more details.
Hope this helps.

Is there a way to use babel plugins relying ont he current filename with babel-loader?

I wrote a plugin for babel that relies on the opts.filename and opts.filenameRelative properties. It seems to be working within babel-loader for the purposes of analyzing the adjacent files, but the filename itself seems to be modified.
I'm wondering if theres a way, using babel-loader, to get access to the full source file path to use for generating a legible id and hash.
babel-loader does indeed pass the filename into the transform function. In my particular case, I was preprocessing typescript files with awesome-typescript-loader, and that was messing with the file path.

eclipse doxygen excluding part of the path name

I'm using Eclipse and Doxygen on a Linux platform. My teams code is controlled with Clearcase. My question is can I use an environment variable as part of the path to excluded?
example: every one on the project has a custom view as part of their path. And I don't want to see that in the documentation.
/view/me/a/b/src/.../...
/view/you/a/b/src/.../...
in each developers view their is an environment variable defined with their view name. ex: $CLEARCASE_ROOT = /view/me
So I'm trying to setup a single Doxygen file for whole team to use..
So I want to do something like EXCLUDE ${CLEARCASE_ROOT}/a/b
Then everybody that generates docs will get the same paths.. Can I do this??
Thanks.
Yes, doxygen supports environment variable expansion in its configuration files, see http://www.doxygen.nl/manual/config.html.
The EXCLUDE option controls which files are parsed by doxygen. It sounds like you want the files to be included, but you want them to be displayed with a relative include path, in that case you probably want to use the STRIP_FROM_INC_PATH option. If there are other absolute paths in the documentation you're attempting to make relative, the STRIP_FROM_PATH option may also come into play.
The syntax is a little different than what you proposed, $() vs. ${}, so you'll want to specify something like:
STRIP_FROM_INC_PATH = $(CLEARCASE_ROOT)/a/b
STRIP_FROM_PATH = $(CLEARCASE_ROOT)

Repeating elements/links in org pages to be published as html?

Is there a simple way to add something like the {Back to Worg's index} to every .org page in a directory which I plan to publish with org-publish-project-alist? Is this accomplished with a #+ tag, or some definition in the .css file?
I looked at how they did it on Worg, and it doesn't look like CSS.
There are a few ways you might be able to do so.
Create a generic file that only includes the details you want in each file. For example:
[[./index.org][Back to index]]
Then use #+include: <filename> at the location in your file where you want the line. (See Include Files)
Alternately you could define a macro in a setupfile (See In-Buffer Settings) that is the definition of the link (or multiple link choices)
#+macro: toIndex [[./index.org][Back to index]]
In both cases it is worth noting that the relative paths are based on the exported file. So a [[../index.org]] will always point to the index.org file in the parent directory, no matter where the setupfile is.

Making stable names for doxygen html docs pages

I need to refer to Doxygen documentation pages. The file names however are not stable as they change after every generation. My idea is to create a symlink to each HTML file created by Doxygen , having a stable and human friendly name. Have anyone tried this?
Actually, it might be very easy just to parse the annotated.html file Doxygen produces. Any documented class shows up there as a line like:
`<tr><td class="indexkey"><a class="el" href="dd/de6/a00548.html">
ImportantClass</a></td>`
The hard problem for me is that I would like to have my file names (i.e. the symlinks) be visible on my server like:
http://www.package.com/com.package.my.ImportantClass.html
[Yes, the code is in java]. So the question actually reads: "how to connect a HTML page by Doxygen with the right java class name and its package name.
You seem to have SHORT_NAMES enabled, which will indeed produce volatile names. When you set SHORT_NAMES to NO in the configuration file (the default), you will get longer names, but these are stable over multiple runs (i.e. they are based on the name, and for functions also on (a hash of) the parameters.