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

Kramdown warnings #967

Merged
merged 2 commits into from Oct 29, 2016

Conversation

Projects
None yet
3 participants
@gpakosz
Copy link
Member

commented Oct 23, 2016

Summary

This PR does two things in two commits:

  • tell which item and rep produces a kramdown warning
  • implements warning filtering (see #675) as kramdown itself as no warning switches

To do

The :warning_filters array should be documented on https://nanoc.ws as part of the filters reference documentation.


# Run filter
io = capturing_stdio do
filter.setup_and_run('{:foo}this is bogus')
end
assert_empty io[:stdout]
assert_equal "kramdown warning: Found span IAL after text - ignoring it\n", io[:stderr]
assert_equal "kramdown warning(s) for item, rep: #{item.identifier}, #{item_rep.name}\n Found span IAL after text - ignoring it\n", io[:stderr]

This comment has been minimized.

Copy link
@ddfreyne

ddfreyne Oct 23, 2016

Member

I’d replace

"… item, rep: #{item.identifier}, #{item_rep.name}"

with

"… #{item_rep.inspect}"
@ddfreyne

This comment has been minimized.

Copy link
Member

commented Oct 23, 2016

Looks good! There’s a couple of style issues that Travis CI complains about still.

warnings = document.warnings
end

if warnings.length != 0

This comment has been minimized.

Copy link
@ddfreyne

ddfreyne Oct 23, 2016

Member

Replace this with warnings.any? (I know Rubocop says warnings.length.nonzero? but that’s not as nice.)

$stderr.puts "kramdown warning: #{warning}"
if (warning_filters)
r = Regexp.union(warning_filters)
warnings = document.warnings.select { |warning| !(r =~ warning) }

This comment has been minimized.

Copy link
@ddfreyne

ddfreyne Oct 23, 2016

Member

Replace

!(r =~ warning)

with

r !~ warning

Or alternatively, replace

select { |warning| !(r =~ warning) }

with

reject { |warning| r =~ warning }
@ddfreyne

This comment has been minimized.

Copy link
Member

commented Oct 23, 2016

Does it make sense to provide the warning filters via the configuration file, rather than arguments to the filter call? That’d make the dup dance unnecessary, and I guess it’d avoid having to copy the filter warnings if you call the :kramdown filter more than once…

@gpakosz gpakosz force-pushed the gpakosz:kramdown-warnings branch from d89ae1f to fc1ec10 Oct 23, 2016

@ddfreyne ddfreyne added this to the 4.3.7 milestone Oct 23, 2016

@gpakosz

This comment has been minimized.

Copy link
Member Author

commented Oct 23, 2016

I took your comments into account.

Well in my setup, I was already doing e.g in nanoc.yaml.

# erb filter options
erb:
  trim_mode: '<>'

and then when filtering

filter :erb, @config[:erb] || {}

A quick grep didn't really exhibit existing filters reading their options straight from @config, do you want to introduce a new behavior? (which kinda opens other questions like @config[:kramdown][:warning_filters] or @config[:kramdown_warning_filters] 🤔 ?)

@gpakosz gpakosz force-pushed the gpakosz:kramdown-warnings branch from fc1ec10 to e30fdf3 Oct 26, 2016

@connorshea

This comment has been minimized.

Copy link

commented Oct 27, 2016

This is awesome, I've wanted this myself. Thanks @gpakosz!

@ddfreyne

This comment has been minimized.

Copy link
Member

commented Oct 29, 2016

I’m OK with leaving it as a filter argument, as it’s more flexible, and still leaves open the option for using the configuration in the way you described.

Is this still WIP or is it ready to go?

@ddfreyne ddfreyne merged commit e51fb4b into nanoc:master Oct 29, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@gpakosz gpakosz deleted the gpakosz:kramdown-warnings branch Feb 28, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.