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

added alphabetic sorting and tag naming configuration #27

Merged
merged 3 commits into from
Oct 9, 2022

Conversation

nebelgrau77
Copy link
Contributor

Hi there!

I am using Sphinx to create some documentation at work, and after searching for a tagging solution I found your fantastic extension!

As I basically want to only use tags (or categories) as my index, I tried to make it easier to customize them. So now there are three additional settings in the conf.py:

  • tags_page_title: this is the wording on top of a tag page, I call it "Category", the default is "Tag"
  • tags_page_header: this is what appears before the tags, the default is "With this tag", in my case "In this category"
  • tags_index_head: the title/header of the toctree in the tags index file that Sphinx generates.

On top of that I also added alphabetic sorting of the tags, both in the tag index and in each tag page. As for the latter, it is not perfect: as it goes by file name, if your article/post/paragraph is "An interesting story" but the actual file name is "zorro_returns.md", then of course it won't work as expected. A solution to this would require some RegEx, I suppose.

I would assume that the alphabetic sorting should be the default behavior, but maybe it should be a flag instead? What do you think?

Anyway, I'm curious to find out what you think about this proposal! I went ahead and added it also to the documentation.

Thanks again for making this fantastic extension!

Copy link
Owner

@melissawm melissawm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome, thank you so much! Only a very minor comment otherwise looks great.

Let me know if you'd like to stick around and contribute more :) Cheers!

@@ -28,7 +28,7 @@ class TagLinks(SphinxDirective):

# Custom attributes
separator = ","
intro_text = "Tags: "
intro_text = "In categories: "
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could probably be configured as well, I guess. We can do this in a follow-up though!

Copy link
Contributor Author

@nebelgrau77 nebelgrau77 Oct 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, makes sense! What should we call it in the config? Something like tags_intro_text maybe?

Edit: I'm trying to do it, but I don't understand what it actually does, as in: where does this text appear in the generated document OK got it :D

content.append("")
content.append("```{toctree}")
content.append("---")
content.append("--------")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is actually unnecessary; the syntax for MyST is actually for this separator to match the one on line 105 below, so it should be just 3 dashes as originally.

Suggested change
content.append("--------")
content.append("---")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha! :)

@nebelgrau77
Copy link
Contributor Author

This looks awesome, thank you so much! Only a very minor comment otherwise looks great.

Let me know if you'd like to stick around and contribute more :) Cheers!

Sure, I'm happy to contribute if I can! This extension really helped me and I will definitely use it, so if I can make it even better, that would be great :)

@nebelgrau77 nebelgrau77 closed this Oct 9, 2022
@nebelgrau77 nebelgrau77 reopened this Oct 9, 2022
@nebelgrau77
Copy link
Contributor Author

I might have made some mess with the commits, do you want me to do them as a separate branch? Or can you approve/merge like this?

Also removes files from tag folder before (re)creating them.
@melissawm melissawm force-pushed the main branch 2 times, most recently from a28104e to a94b81e Compare October 9, 2022 17:43
Also adds the tags output dir to .gitignore for convenience, and fixes a typo.
@melissawm
Copy link
Owner

Ok I think this is good to go! My last comment is that usually to keep features isolated from the main branch, it is a good idea to create a feature branch when you want to submit a PR.

I'll cut a release with these changes right now.

Thanks again 🎉

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

Successfully merging this pull request may close these issues.

2 participants