kai687 / sphinxawesome-sampdirective Goto Github PK
View Code? Open in Web Editor NEWA Sphinx directive for code blocks with highlighted placeholder variables.
License: MIT License
A Sphinx directive for code blocks with highlighted placeholder variables.
License: MIT License
I have to think a bit more about semantics of this construct. I made the following observations:
:samp:
role: A piece of literal text, such as code. Within the contents, you can use curly braces to indicate a “variable” part Sphinx doc<samp>
element: enclose inline text which represents sample (or quoted) output from a computer program. MDN<samp>
element seems to be narrower then that of the :samp:
reStructuredText role.How I've used it mostly was to mark up a placeholder for user input. User input is supposed to be marked up by the <kbd>
element:
:kbd:
role: Mark a sequence of keystrokes. Sphinx docCurrently, the placeholder part is an 'emphasis' token, with a class of var
for variable
part. It is maybe ok to leave it like that. In HTML, this becomes <em class="var">
.
I think, mostly I want to be able to mark up "an inline character sequence that is a placeholder that the user has to replace with the actual text", such as username, URL, etc.
Maybe better would be <code class="placeholder">
because it could be either program output or user input. (Although echoed user input is probably <kbd>
inside <samp>
?
Changing the returned node type would be a breaking change.
This should get a highlighted prompt character:
$ echo "Something"
This should not:
$HOME/.bin/something
Write a test for
.. samp::
$ do stuff /here/{PLACEHOLDER}/
And if that works fine, write another test for {PLACE_HOLDER}. I might need to modify the token regex.
It would also be nice to log the token/node list after parsing on debug level.
This issue is related to kai687/sphinxawesome-theme#45
This will not be parsed correctly by the directive:
stuff = { "item" : "{PLACEHOLDER}" }
If I can find out, how to only take the innermost pair or curly braces as placeholder, I can fix it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.