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

Section title out of sequence warnings may be generated when using operation macro #628

Closed
wants to merge 1 commit into from
Closed

Section title out of sequence warnings may be generated when using operation macro #628

wants to merge 1 commit into from

Conversation

ahus1
Copy link
Contributor

@ahus1 ahus1 commented Aug 2, 2019

I've run the sample rest-notes-spring-hateoas locally using gradlew asciidoctor and saw that it generated lots of error messages like

asciidoctor: WARNING: api-guide.adoc: line 2: section title out of sequence: expected levels 0 or 1, got level 4

I traced this down to operation_block_macro.rb and changed it so that the block level is adjusted after Asciidoctor.load when the blocks are added to the parent. I assume this is safe when there are no nested blocks.

Once I change it, the output is still correct and the warning message is gone.

Renderings with standard section depth first to avoid warnings that
document starts with level 3 headings. Adjust block level when
adding the content to the parent.
def write_title(content, snippet, level, id, snippet_titles)
section_level = '=' * (level + 1)
def write_title(content, snippet, id, snippet_titles)
section_level = '=='
Copy link
Member

@wilkinsona wilkinsona Aug 13, 2019

Choose a reason for hiding this comment

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

Switch to hardcoding two = feels like it may cause a regression to me. For example, will it not now be wrong if the macro is used in a deeply nested section?

Copy link
Contributor Author

@ahus1 ahus1 Aug 15, 2019

Choose a reason for hiding this comment

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

The new line 53 will adjust the level of all top level blocks the moment they are inserted. This avoid the warning that would otherwise occur when starting with a section of a too high level, and avoid having a regression.

@luvarqpp
Copy link
Contributor

I am using this patch and it is working for me. I would be happy to see it in milestone 2.0.4.RELEASE along with #581 solved.

@wilkinsona wilkinsona added this to the 2.0.4.RELEASE milestone Aug 30, 2019
@wilkinsona wilkinsona changed the title renderings with standard section depth first to avoid warnings Section title out of sequence warnings may be generated when using operation macro Aug 30, 2019
wilkinsona pushed a commit that referenced this pull request Aug 30, 2019
Renderings with standard section depth first to avoid warnings that
document starts with level 3 headings. Adjust block level when
adding the content to the parent.

See gh-628
@wilkinsona
Copy link
Member

Thanks for the PR, @ahus1. The proposed changes are now in master along with a polishing commit that updated the tests to cover the scenario that previously generated a warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants