Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple languages by tab? #54

Open
maelle opened this issue May 9, 2020 · 2 comments · May be fixed by #55
Open

Multiple languages by tab? #54

maelle opened this issue May 9, 2020 · 2 comments · May be fixed by #55

Comments

@maelle
Copy link

maelle commented May 9, 2020

Thanks for creating this useful theme!

I have a question that might be a limitation of Slatedocs itself.

I'd like to be able to define tabs that show several languages.

For instance, for documenting a web API that has an R client providing parsed output

  • A tab with R code and R output
  • A tab with shell commands and JSON/XML output.

My workaround is to define the second tab for "JavaScript" because highlighting shell/JSON/XML as if it were JavaScript does not look too horrible.

Any insight on how to tweak this theme to be able to use something like

[[params.language_tabs]]
  key = "r"
  name = "R" 
[[params.language_tabs]]
  key = "shell"
  name = "Shell"
  otherlangs = ["json", "xml"] 

is welcome. 🙂 I guess I'd need to tinker with https://github.com/bep/docuapi/blob/master/assets/js/slate/app/_lang.js and

<a href="#" data-language-name="{{ .key }}">{{ .name }}</a>
(where there could be, say, data-language-name and data-languages-name, one for the URL stuff -- key, one for the hiding/showing -- key+otherlangs 🤔) and
<body class="index" data-languages="{{ with .Site.Params.language_tabs }}[{{ range $i,$e := . }}{{- if $i -}}, {{ end -}}{{ printf " %q " $e.key }}{{end}}]{{ end }}">
(that'd use key and otherlangs in my "proposal").

@bep
Copy link
Owner

bep commented May 9, 2020

I'm not sure how generally usefull such a feature would be (I understand that you need it), but it should be possible to do the mods in this theme. Your thoughts above looks sensible.

@maelle
Copy link
Author

maelle commented May 10, 2020

Cool, I'll experiment in a fork next week. In the "worst case", I'll keep my edits as custom layouts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants