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

attrs_block support for name attribute #726

Closed
Sporiff opened this issue Feb 28, 2023 · 4 comments
Closed

attrs_block support for name attribute #726

Sporiff opened this issue Feb 28, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@Sporiff
Copy link

Sporiff commented Feb 28, 2023

Context

#703 introduced a really helpful extension which makes writing code blocks a lot simpler. In the majority of cases, being able to specify the linenos and emphasize-lines parameters is sufficient for smaller blocks. The only other thing I find myself needing to do frequently is name the blocks.

For context: I work on a project where we document a lot of duplicate classes/functions across a number of platforms. I use the code block name to generate tooltips for hovering over function names in the document and show the invocation as it is in the code.

My team has indicated that using the standard ```{language} invocation for code blocks makes their lives a lot simpler than needing to remember the {code-block} directive and additional parameters inside the block, and that the syntax using the `attrs_block` is more readable to them in the source document than something with nested parameters. If possible, I'd like to be able to fully replace the `{code-block}` invocation in my project since we use very few of Sphinx's other features for these blocks.

Proposal

If possible, I'd like to be able to use the new functionality introduced in the attrs_block plugin to replace the following syntax:

```{code-block} java
:name: android-method1

public void method1 (boolean argument)
```

With something like this:

{name="android-method1"}
```java
public void method1 (boolean argument)
```

Tasks and updates

No response

@Sporiff Sporiff added the enhancement New feature or request label Feb 28, 2023
@welcome
Copy link

welcome bot commented Feb 28, 2023

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

@chrisjsewell
Copy link
Member

Hey @Sporiff thanks, and you should be able to already!

For all uses of attrs_block #name specifies the id (aka name) and the .class specifies classes, e.g.

{#name .class1 .class2}
```python
hallo = "world"
```

give it a go and let me know if that works for you 😄

@Sporiff
Copy link
Author

Sporiff commented Feb 28, 2023

Hi @chrisjsewell that works perfectly! Chalk it up to my lack of reading comprehension 😜

I think this plugin will make our lives a lot easier. Thank you for all you do!

@Sporiff Sporiff closed this as completed Feb 28, 2023
@chrisjsewell
Copy link
Member

No worries! Obviously if you think the documentation could be improved then let me know! (although check out #717 first)

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

No branches or pull requests

2 participants