question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to support custom directives?

See original GitHub issue

It’d be very nice to be able to translate custom directives, like a .. video:: one I’ve created for my doc.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ocayrolcommented, Sep 16, 2020

You can have a look at https://www.sphinx-doc.org/en/master/development/tutorials/todo.html to see a little example. The link you posted above ( https://github.com/ankita240796/docs/blob/f57ebfbb3dc82b256334efbf6a697ef612b36890/video.py ) is another example.

Inside a Sphinx extension, you define a new directive that will create a new type of node inside the document tree. Thus, you also define a new node class in the extension. Of course, you now have to explain how you would transform this new type of node into HTML, Latex or, here, Markdown. So, you write several “functions” that can transform this type of node into an output format. These functions will be dynamically weaved into a node visitor as visit / depart methods (so you need a visit function and a depart function and you have to be compliant with the node visitor internal behaviour). When you register the new type of node in the Sphinx application with the add_node method, you also give the visit / depart functions for each format you want to support.

In the “todo” tutorial, this is what is done for the todo node. In the “video” example, this is also what is done for the video_node.

0reactions
Tilix4commented, Sep 15, 2020

That seems nice but I don’t really get all the possibilities? Will you provide some code examples?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use and create custom directives in Angular
There are a lot of built-in Directives available in Angular which you can easily use. In this section, we will use two very...
Read more >
Creating schema directives - Apollo GraphQL Docs
Supported locations. Your custom directive can appear only in the schema locations you list after the on keyword in the directive's definition.
Read more >
Using Custom Directives with Apollo Federation
Yes! We can define a custom directive in an implementing service and apply it to a field for a type that has been...
Read more >
Using a Custom Directive | Pluralsight
Hello friends, In this guide, we're going to learn about custom directives. In Angular, directives play an important role. There are many ...
Read more >
support custom directives in federated schemas · Issue #145
The filtered directives in the line you're referencing are used to print the directive declarations like directive @foo on FIELD_DEFINITION . It ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found