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

How does the only syntax take effect on titles #1212

Open
IamJasonBoy opened this issue Oct 23, 2023 · 3 comments
Open

How does the only syntax take effect on titles #1212

IamJasonBoy opened this issue Oct 23, 2023 · 3 comments

Comments

@IamJasonBoy
Copy link

IamJasonBoy commented Oct 23, 2023

# %%
# 页面地址
# ****************************************************************************
# * 说明文档

PS:This is a chapter or title, and I hope only can take effect for that title. How should I write the code

# %%
# .. only:: saas
# 页面地址
# ****************************************************************************
# * 说明文档

From the above example, should it be written like this?
But it doesn't actually take effect

Only syntax takes effect on chapters ?
Only syntax takes effect on code blocks ?

@drammock
Copy link
Contributor

See the sphinx documentation: https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-only

Warning

This directive is designed to control only content of document. It could not control sections, labels and so on.

@IamJasonBoy
Copy link
Author

**
I know the use of only
I want to validate the title, but these statements are invalid and have been reported incorrectly
The child of the only syntax needs to be indented by four characters,
Using sphinx gallery is written in py file, I don't know how to write it
**

ERR 1

# %%
# .. only:: saas
# 页面地址
# ****************************************************************************
# * 说明文档

ERR 2

# %%
# .. only:: saas
#     页面地址
#     ****************************************************************************
#     * 说明文档

@drammock
Copy link
Contributor

Please read the doc I linked to more carefully. In particular, the part that I quoted says that the .. only:: directive DOES NOT WORK to hide section titles, labels, etc.

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

No branches or pull requests

2 participants