-
Notifications
You must be signed in to change notification settings - Fork 414
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
[WIP] Allow nested categories with recursive navigation. #982
base: master
Are you sure you want to change the base?
Conversation
Thanks for the PR, brave place to start! Will look at the code a bit more later. I think the yaml format is OK; agree that just handling whatever depth the user wants is probably fine. On the design, I'm not sure users will expect the child abstract hierarchy to appear in each parent abstract. It feels to me as though it distracts from the discussion of the parent topic. Maybe include the child subsections instead in a special Task at the bottom of the page task list that actually links in the normal way (with twisty) to the child section. On the left nav, I guess I think yes the subsection structure should be reflected with some kind of indentation - wish I could help more on the style front! You should use the misc_jazzy_features specs project to include tests for the feature. |
@johnfairh That‘s the integration tests right? Yeah I am not too keen on each abstract as well. What‘s twisty? And yeah, the headers should probably link, didn‘t have any time yesterday to integrate that (though it should be easy). |
Pretty sure it’s a disclosure triangle, like this: |
(Sorry and ty @1ec5 for translating!) |
@johnfairh Ah gotcha. Question would be, whether to keep the subsections seperate or add them to the tasks array. |
New thought: we should just include the subsection link in the children array where the user wrote it in their markdown, I think that's the least surprising behavior. [Letting markdown specify headings is a separate issue!] |
@johnfairh I don't quite follow what you mean. Can you elaborate? |
@johnfairh Did you have some time to look at the implementation and decide whether to use a new property (like the current implementation) or use the existing children array? When that‘s decided, I can start working on tests and fixing up things. Sorry if I am stressing you 😬, this would help a ton with our docs :) |
Sorry missed I owed you a response here! Yes I looked through it, I think you've nicely captured the recursive building part of it and that it will work to treat nested categories as regular children. PR #985 is a step on the way, deals with linking from category pages to items without an abstract; I'm planning to look at the left nav design/layout part next. |
@johnfairh Cool, will try to get it changed to use children and tasks over the next few days. |
As mentioned elsewhere, I think this is a great idea. I’d love to see project directory parsing as a custom category source included in this PR. Wondering if I can help in any way? |
@galli-leo dw, I got it - take a look at this branch & see what you think. I've treated the nested categories like everything else in the left nav so they are less heavy than in yours above, 🤷♂️ if this is OK - mostly been persuading the styles to nest reasonably. @JUSTINMKAUFMAN would be a separate PR. You would need to write a version of this function that builds the category structure from the types returned by SourceKitten - they each have a |
@johnfairh Well also just got done, treating them like normal children 😬 . Also your mustache templates will never render, since you will have infinite recursion. If there is no children in the current context (i.e. a non category) mustache will try the parent context. Obviously that one has children, so it will render the parent nav again and again. See my branch for how I fixed that. I like the idea of creating a new type, that makes a lot of sense. I still think we should include the level, so that we can always use the correct h tag. I agree that they are quite heavy in my implementation, but that's mostly because of the style sheets. I think gradually lowering e.g. font-size for sub and subsubsections makes a lot of sense, while still letting them standout to the rest. What do you think of my tasks implementation? When you click on a subcategories heading, it discloses that one's abstract now. We could also include the subsections in the normal tasks array, though I don't know how that will play out with mark comments. What do you think? Also would it make sense to include the child items of the category in the "popup"? Live demo of the latest commit is here: https://galli.me/jazzy-demo/nested |
The templates are fine lol - easy to misread 😉 Yep including the abstract if there is one (suspect often will not be) makes sense - should come out easily as part of treating the nested category like other children [I think this is what you mean by "including in the normal tasks array"] The design you can see in eg. classes is to include just the abstract in the parent page and leave the next level of children to the next page down. I misunderstood how much help you were asking for with the visual design here - will let you get on! |
@johnfairh Should I merge in your branch? Or are you planning on implementing this? |
Take as much/little as you need - if you need to do things a different way to get the visual effects you want for the headings and on the category pages then go ahead.. |
@johnfairh So I integrated some of your changes (namely moving categories into their own class) into my pr. I think it's mostly ready for a review now, works quite well imo. Checkout https://galli.me/jazzy-demo/nested for a visual demo. Or should I add some tests (and fix the old ones due to adding headings in the nav) before a review? I made it, so that the Sub categories follow the same style as a mark heading and reveal the abstract as well as their items on clicking on it. Let me know, if I should also include the sub sub categories in that reveal. Should I try to fix the js code not revealing the sub category as well as an item of the subcategory when clicked on? Furthermore, should I try to fix those cyclomatic complexity errors from rubycop, or just ignore them with a comment? Not sure why it complains about the spacing for self.level = level as well, seems to be the same as your self.name = name. |
…ed an example with nested categories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Added some code nitpicks & a less trivial thought about category names.
I'm pretty sure that the left nav style needs to remain the same as now, certainly for sites that aren't using nested categories -- right now (no nested categories) it goes from:
to
From a design point of view, the sidebar is almost always less important than the body so needs not to have these big highly-spaced headings that are more eye-catching than stuff in the body.
The category headings in the body should probably use a different class or something from the mark headings: we know that some users do not like the mark headings and use custom CSS to suppress them.
There are various existing problems with the js reveal/hide code -- I would save fixes for another PR.
Yes, strong default action is to fix the rubocop errors - they're usually pointing out good Ruby style points.
Either need apple + jony theme changes or docs + something to detect the incompatibility -- generated html looks OK at first but behaves pretty oddly.
I haven't checked how this looks in Dash.
lib/jazzy/doc_builder.rb
Outdated
@@ -105,6 +111,13 @@ def self.each_doc(output_dir, docs, &block) | |||
doc.children, | |||
&block | |||
) | |||
if doc.subsections != nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change not required, subsections
unused.
lib/jazzy/doc_builder.rb
Outdated
alternative_abstract = subsection.alternative_abstract | ||
if alternative_abstract | ||
overview = render(subsection, alternative_abstract) + overview | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to pull out these 5-6 lines instead of duplicating them.
lib/jazzy/source_category.rb
Outdated
|
||
def initialize(group, name, abstract, url_name, level = 1) | ||
super() | ||
self.type = SourceDeclaration::Type.category |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this is supposed to be rename of Type.overview
or something else - if a rename then need to delete overview and add a category?
helper to get rid of the manual comparisons everywhere. Usually better to do refactorings in separate commits to new code, makes it easier for people to read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a rename, an additional type. I think it makes the filter and partition calls in doc_builder more logical. Will add a helper.
Should I move this to a separate commit? Or just leave it for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. overview
is the type used for these category pages. You could rename it (as long as this doesn't change existing URLs) but we don't need an additional type.
lib/jazzy/source_category.rb
Outdated
self.abstract = Markdown.render(abstract) | ||
self.children = group | ||
self.parameters = [] | ||
self.mark = SourceMark.new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need a mark if it's not going into the children/tasks render structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I left it from your code. Will remove.
lib/jazzy/source_category.rb
Outdated
self.children = group | ||
self.parameters = [] | ||
self.mark = SourceMark.new | ||
self.level = level |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rubocop complains about this line because it can't figure out what the spaces are for: either use just 1 or line up the =
with the line above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A gotcha, will fix.
lib/jazzy/source_declaration.rb
Outdated
@@ -99,6 +99,8 @@ def display_other_language_declaration | |||
attr_accessor :end_line | |||
attr_accessor :nav_order | |||
attr_accessor :url_name | |||
attr_accessor :level | |||
attr_accessor :subsections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(subsections
not used any more)
lib/jazzy/sourcekitten.rb
Outdated
doc.children = make_doc_urls(doc.children) | ||
if doc.children.count > 0 | ||
doc.children = make_doc_urls(doc.children) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think undo this change, original code is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be leftover from your branch with the other changes, will remove.
lib/jazzy/sourcekitten.rb
Outdated
doc.children = make_doc_urls(doc.children) | ||
if doc.children.count > 0 | ||
doc.children = make_doc_urls(doc.children) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This url construction part leaves all category pages in the same directory. I'm not sure it's obvious that users should not duplicate subcategory names even if they are in different parent trees.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you rather have them moved to subdirectories or have a note in the config info?
I thought about adding a section to the README anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requiring subcategory name uniqueness feels like a footgun/defect creator. Putting the pages in subdirs should work.
@@ -49,7 +49,7 @@ | |||
</section> | |||
|
|||
{{> tasks}} | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(can tidy this up)
Should have time tomorrow to fix those.
Do you propose going back to just tags or styling the headings differently? I agree it's a bit too big, I just wanted to make the distinction between subsections clear for demo purposes.
Will add a custom CSS class. Should the style be still the same?
Should have time to fix those tomorrow as well.
Yeah I wanted to have one theme finalized, before working on the other ones. Will do those when fullwidth is good to go.
I have taken a quick look and it seems fine, but the sections are unfortunately not nested inside dash. Not sure if that's possible or not. |
I guess find some other way of styling the 'sub'categories (same weight as the top categories?) - or leave them styled as they come out and rely on the indentation to indicate the hierarchy.
Yes I think that makes sense.
Sounds good! |
…ied up css and fixed a few other things.
lib/jazzy/source_category.rb
Outdated
children = category['children'].flat_map do |child| | ||
if child.is_a?(Hash) | ||
# Nested category, recurse | ||
children, docs = group_custom_categories(docs, [child], level + 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johnfairh I renamed docs_with_name to children to a) make rubocop happy and b) make it's purpose clearer.
Is that ok?
@johnfairh I toned the navigation stylings down a bit. The only change now is font-weight, though I had to increase the font-size a little, or else the headings looked smaller (not sure why). Can tone them down even more, if you think that's better. IMO having some differentiation through font-weight in addition makes it a bit easier to read. |
Code changes look great. I think the I appreciate the work on the styling. There's still additional vertical whitespace above heading elements (?); I would like the default weights to be as they are currently -- you can always override in your own projects. |
@johnfairh Sounds good. Moved level to a computed property (not sure if that's what you call it in ruby). Also made the categories look like before. I still added some top margin to all sub and subsub categories, because they would have had less spacing to the items before them than after them. |
Thanks! This all looks good to me now -- code nits that you can get rid of the If you could update your demo site to reflect the most recent theme update + @jpsim can OK the design then I reckon good to update the other themes and merge it. (sorry for the delay: this time my excuse is that GitHub doesn't email comment edits!) |
Fixed both and updated the demo site as requested. BTW. maybe it would be a cool idea to host the generated integration specs somewhere? So a reviewer and even pr author can easily look at changes? Additionally, a visual diff would be even cooler. Is that something you have considered?
No worries! Out of curiosity, do you get notifications for commits to a pr? If not should I leave messages for new commits in the future? |
👍 thanks. FYI the specs are in the Yep, commits notify! It might just be me but I usually wait for a comment to indicate "OK i've stopped pushing stuff, please take a look" :-) |
@johnfairh I will wait on the integration_specs pr until all themes are finished. @jpsim If you are ok with the design, I can start on the other themes :) |
Bump |
@galli-leo @johnfairh is there any progress/plans with this feature? |
Is there any update for this feature? |
Overview
So I started working on allowing nested categories for custom categories. Currently there is no limit on the amount of nesting (i.e. levels). This is achieved through nested partials as well as keeping track of the level, and using that in the header tag (
<h{{level}}>
).Current Implementation
Questions
Generally, I would really appreciate some help with the css and generally the look & feel.
Screenshots
Created with the following yaml:
Linked
Closes #624