Skip to content

Add support for unit closer pages in toc #408

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TylerZeroMaster
Copy link
Contributor

@TylerZeroMaster TylerZeroMaster commented Apr 22, 2025

https://openstax.atlassian.net/browse/CORE-930

The default for unit pages will remain the same: treat them as introductions

This new unit-closer class supports specifying pages that should appear at the end of the unit.

I debated on if this should be done structurally instead, like this:

      # if this page is inside a unit that has at least one chapter and there are no chapters
      # after this page
      @is_unit_closer ||= has_ancestor?(:unit) and
        ancestor(:unit).element_children.only(ChapterElement).any? and
        ancestor(:unit)
          .element_children
          .drop_while { |el| el[:id] != self[:id] }
          .none? { |el| el[:'data-type'] == 'chapter' }

I decided not to do this since introductions are done with classes and it could be useful to select unit closers by a css selector. I am a little concerned that using a class could cause confusing behavior if a unit-closer is placed before the end of a unit.

The default for unit pages will remain the same: treat them as introductions

This new unit-closer class supports specifying pages that should appear at the end of the unit
Copy link

codecov bot commented Apr 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (abe1663) to head (456499f).

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #408   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          217       217           
  Lines         3583      3588    +5     
=========================================
+ Hits          3583      3588    +5     
Files with missing lines Coverage Δ
lib/kitchen/directions/bake_toc.rb 100.00% <100.00%> (ø)
lib/kitchen/page_element.rb 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TylerZeroMaster TylerZeroMaster requested a review from jivey April 23, 2025 16:12
Copy link
Member

@jivey jivey left a comment

Choose a reason for hiding this comment

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

I don't have a deep understanding of the cookbook but this appears like a solid approach.

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