Coder Social home page Coder Social logo

kai687 / sphinxawesome-sampdirective Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 1.0 1.12 MB

A Sphinx directive for code blocks with highlighted placeholder variables.

License: MIT License

Python 100.00%
documentation documentation-tool python sphinx sphinx-extension

sphinxawesome-sampdirective's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar jdillard avatar kai687 avatar

Forkers

ttttttttq

sphinxawesome-sampdirective's Issues

Better semantics

I have to think a bit more about semantics of this construct. I made the following observations:

  • The Sphinx :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
  • The HTML <samp> element: enclose inline text which represents sample (or quoted) output from a computer program. MDN
  • The intended semantics for the <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:

  • represents a span of inline text denoting textual user input from a keyboard, voice input, or any other text entry device. MDN There are examples on that page on how to represent user input in various combinations
  • The Sphinx :kbd: role: Mark a sequence of keystrokes. Sphinx doc
  • it looks like the Sphinx role is narrower in semantic (key combos rather than generic user input).

Currently, 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.

Investigate bug

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

Improve handling of edge cases

  • empty set {} should be rendered as text
  • escaped curly braces should be rendered as single curly braces
  • single curly braces { or } should be rendered as text

(Spun off from issue #4 and pull request #5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.