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

Module-ify built-in function documentation #366

Merged
merged 5 commits into from
Sep 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ use Rack::Rewrite do
r301 '/documentation/file.SASS_CHANGELOG.html', 'https://github.com/sass/dart-sass/blob/master/CHANGELOG.md'
r301 '/documentation/file.INDENTED_SYNTAX.html', '/documentation/syntax'
r301 '/documentation/file.SCSS_FOR_SASS_USERS.html', '/documentation/syntax'
r301 '/documentation/Sass/Script/Functions.html', '/documentation/functions'
r301 '/documentation/Sass/Script/Functions', '/documentation/functions'
r301 '/documentation/Sass/Script/Functions.html', '/documentation/modules'
r301 '/documentation/Sass/Script/Functions', '/documentation/modules'
r301 %r{/documentation/(Sass.*)}, 'http://www.rubydoc.info/gems/sass/$1'
r301 '/documentation/functions/css', '/documentation/at-rules/function#plain-css-functions'
r301 %r{/documentation/functions(.*)}, '/documentation/modules$1'

r301 %r{/(.+)/$}, '/$1'
r301 %r{/(.+)/index\.html$}, '/$1'
Expand Down
17 changes: 8 additions & 9 deletions data/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,15 @@ toc:
- Numeric: /documentation/operators/numeric
- String: /documentation/operators/string
- Boolean: /documentation/operators/boolean
- Built-In Functions: /documentation/functions
- Built-In Modules: /documentation/modules
:children:
- Plain CSS: /documentation/functions/css
- Numbers: /documentation/functions/math
- Strings: /documentation/functions/string
- Colors: /documentation/functions/color
- Lists: /documentation/functions/list
- Maps: /documentation/functions/map
- Selectors: /documentation/functions/selector
- Introspection: /documentation/functions/meta
- <code>sass:color</code>: /documentation/modules/color
- <code>sass:list</code>: /documentation/modules/list
- <code>sass:map</code>: /documentation/modules/map
- <code>sass:math</code>: /documentation/modules/math
- <code>sass:meta</code>: /documentation/modules/meta
- <code>sass:selector</code>: /documentation/modules/selector
- <code>sass:string</code>: /documentation/modules/string
- Breaking Changes: /documentation/breaking-changes
:children:
- Extending Compound Selectors: /documentation/breaking-changes/extend-compound
Expand Down
11 changes: 6 additions & 5 deletions helpers/sass_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ def _impl_status_row(name, status)
def function(*signatures, returns: nil)
names = Set.new
highlighted_signatures = signatures.map do |signature|
name = signature.split("(").first
name, rest = signature.split("(", 2)

Choose a reason for hiding this comment

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

Lint/UselessAssignment: Useless assignment to variable - rest. Use _ or _rest as a variable name to indicate that it won't be used.

name_without_namespace = name.split(".").last
html = Nokogiri::HTML(_render_markdown(<<MARKDOWN))
```scss
@function #{signature}
Expand All @@ -446,9 +447,9 @@ def function(*signatures, returns: nil)
take_while {|el| el.text != "{}"}[1...-1]

# Add a class to make it easier to index function documentation.
unless names.include?(name)
names << name
name_element = signature_elements.find {|el| el.text == name}
unless names.include?(name_without_namespace)
names << name_without_namespace
name_element = signature_elements.find {|el| el.text == name_without_namespace}

Choose a reason for hiding this comment

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

Style/CollectionMethods: Prefer detect over find.
Layout/SpaceInsideBlockBraces: Space between { and | missing.
Metrics/LineLength: Line is too long. [87/80]
Layout/SpaceInsideBlockBraces: Space missing inside }.

name_element.add_class ".docSearch-function"
name_element['name'] = name
end
Expand Down Expand Up @@ -490,7 +491,7 @@ def return_type_link(return_type)
when 'boolean'; link_to type, '/documentation/values/booleans'
when 'null'; link_to '<code>null</code>', '/documentation/values/null'
when 'function'; link_to type, '/documentation/values/functions'
when 'selector'; link_to type, '/documentation/functions/selector#selector-values'
when 'selector'; link_to type, '/documentation/modules/selector#selector-values'

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Metrics/LineLength: Line is too long. [86/80]

else raise "Unknown type #{type}"
end
end.join(" | ")
Expand Down
176 changes: 93 additions & 83 deletions source/assets/js/components/redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ if (window.location.hash) {
"#color_operations": "/documentation/operators/color",
"#string_operations": "/documentation/operators/string",
"#boolean_operations": "/documentation/operators/boolean",
"#list_operations": "/documentation/functions/list",
"#list_operations": "/documentation/modules/list",
"#parentheses": "/documentation/operators#parentheses",
"#functions": "/documentation/functions",
"#functions": "/documentation/modules",
"#keyword_arguments": "/documentation/at-rules/function#keyword-arguments",
"#interpolation_": "/documentation/interpolation",
"#parent-script": "/documentation/style-rules/parent-selector#in-sassscript",
Expand Down Expand Up @@ -97,93 +97,103 @@ if (window.location.hash) {
}

if (redirect) window.location.href = redirect;
} else if (window.location.pathname == "/documentation/functions") {
} else if (window.location.pathname == "/documentation/modules") {
var redirects = {
"#declare-class_method": "/ruby-sass",
"#random_number_generator-class_method": "/ruby-sass",
"#random_seed=-class_method": "/ruby-sass",
"#signature-class_method": "/ruby-sass",
"#abs-instance_method": "/documentation/functions/math#abs",
"#adjust_color-instance_method": "/documentation/functions/color#adjust-color",
"#adjust_hue-instance_method": "/documentation/functions/color#adjust-hue",
"#alpha-instance_method": "/documentation/functions/color#alpha",
"#append-instance_method": "/documentation/functions/list#append",
"#blue-instance_method": "/documentation/functions/color#blue",
"#call-instance_method": "/documentation/functions/meta#call",
"#ceil-instance_method": "/documentation/functions/math#ceil",
"#change_color-instance_method": "/documentation/functions/color#change-color",
"#comparable-instance_method": "/documentation/functions/math#comparable",
"#complement-instance_method": "/documentation/functions/color#complement",
"#content_exists-instance_method": "/documentation/functions/meta#content-exists",
"#darken-instance_method": "/documentation/functions/color#darken",
"#desaturate-instance_method": "/documentation/functions/color#desaturate",
"#feature_exists-instance_method": "/documentation/functions/meta#feature-exists",
"#floor-instance_method": "/documentation/functions/math#floor",
"#get_function-instance_method": "/documentation/functions/meta#get-function",
"#global_variable_exists-instance_method": "/documentation/functions/meta#global-variable-exists",
"#grayscale-instance_method": "/documentation/functions/color#grayscale",
"#green-instance_method": "/documentation/functions/color#green",
"#hsl-instance_method": "/documentation/functions/color#hsl",
"#hsla-instance_method": "/documentation/functions/color#hsla",
"#hue-instance_method": "/documentation/functions/color#hue",
"#ie_hex_str-instance_method": "/documentation/functions/color#ie-hex-str",
"#abs-instance_method": "/documentation/modules/math#abs",
"#adjust_color-instance_method": "/documentation/modules/color#adjust",
"#adjust_hue-instance_method": "/documentation/modules/color#adjust-hue",
"#alpha-instance_method": "/documentation/modules/color#alpha",
"#append-instance_method": "/documentation/modules/list#append",
"#blue-instance_method": "/documentation/modules/color#blue",
"#call-instance_method": "/documentation/modules/meta#call",
"#ceil-instance_method": "/documentation/modules/math#ceil",
"#change_color-instance_method": "/documentation/modules/color#change",
"#comparable-instance_method": "/documentation/modules/math#compatible",
"#complement-instance_method": "/documentation/modules/color#complement",
"#content_exists-instance_method": "/documentation/modules/meta#content-exists",

Choose a reason for hiding this comment

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

Line is too long.

"#darken-instance_method": "/documentation/modules/color#darken",
"#desaturate-instance_method": "/documentation/modules/color#desaturate",
"#feature_exists-instance_method": "/documentation/modules/meta#feature-exists",

Choose a reason for hiding this comment

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

Line is too long.

"#floor-instance_method": "/documentation/modules/math#floor",
"#get_function-instance_method": "/documentation/modules/meta#get-function",

Choose a reason for hiding this comment

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

Line is too long.

"#global_variable_exists-instance_method": "/documentation/modules/meta#global-variable-exists",

Choose a reason for hiding this comment

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

Line is too long.

"#grayscale-instance_method": "/documentation/modules/color#grayscale",
"#green-instance_method": "/documentation/modules/color#green",
"#hsl-instance_method": "/documentation/modules/color#hsl",
"#hsla-instance_method": "/documentation/modules/color#hsla",
"#hue-instance_method": "/documentation/modules/color#hue",
"#ie_hex_str-instance_method": "/documentation/modules/color#ie-hex-str",
"#if-instance_method": "/documentation/#if",
"#index-instance_method": "/documentation/functions/list#index",
"#inspect-instance_method": "/documentation/functions/meta#inspect",
"#invert-instance_method": "/documentation/functions/color#invert",
"#is_bracketed-instance_method": "/documentation/functions/list#is-bracketed",
"#is_superselector-instance_method": "/documentation/functions/selector#is-superselector",
"#join-instance_method": "/documentation/functions/list#join",
"#keywords-instance_method": "/documentation/functions/meta#keywords",
"#length-instance_method": "/documentation/functions/list#length",
"#lighten-instance_method": "/documentation/functions/color#lighten",
"#lightness-instance_method": "/documentation/functions/color#lightness",
"#list_separator-instance_method": "/documentation/functions/list#list-separator",
"#map_get-instance_method": "/documentation/functions/map#map-get",
"#map_has_key-instance_method": "/documentation/functions/map#map-has-key",
"#map_keys-instance_method": "/documentation/functions/map#map-keys",
"#map_merge-instance_method": "/documentation/functions/map#map-merge",
"#map_remove-instance_method": "/documentation/functions/map#map-remove",
"#map_values-instance_method": "/documentation/functions/map#map-values",
"#max-instance_method": "/documentation/functions/math#max",
"#min-instance_method": "/documentation/functions/math#min",
"#mix-instance_method": "/documentation/functions/color#mix",
"#mixin_exists-instance_method": "/documentation/functions/meta#mixin-exists",
"#nth-instance_method": "/documentation/functions/list#nth",
"#opacify-instance_method": "/documentation/functions/color#opacify",
"#opacity-instance_method": "/documentation/functions/color#opacity",
"#percentage-instance_method": "/documentation/functions/math#percentage",
"#quote-instance_method": "/documentation/functions/string#quote",
"#random-instance_method": "/documentation/functions/math#random",
"#red-instance_method": "/documentation/functions/color#red",
"#rgb-instance_method": "/documentation/functions/color#rgb",
"#rgba-instance_method": "/documentation/functions/color#rgba",
"#round-instance_method": "/documentation/functions/math#round",
"#saturate-instance_method": "/documentation/functions/color#saturate",
"#saturation-instance_method": "/documentation/functions/color#saturation",
"#scale_color-instance_method": "/documentation/functions/color#scale-color",
"#selector_append-instance_method": "/documentation/functions/selector#selector-append",
"#selector_extend-instance_method": "/documentation/functions/selector#selector-extend",
"#selector_nest-instance_method": "/documentation/functions/selector#selector-nest",
"#selector_parse-instance_method": "/documentation/functions/selector#selector-parse",
"#selector_replace-instance_method": "/documentation/functions/selector#selector-replace",
"#selector_unify-instance_method": "/documentation/functions/selector#selector-unify",
"#set-instance_method": "/documentation/functions/list#set",
"#simple_selectors-instance_method": "/documentation/functions/selector#simple-selectors",
"#str_index-instance_method": "/documentation/functions/string#str-index",
"#str_insert-instance_method": "/documentation/functions/string#str-insert",
"#str_length-instance_method": "/documentation/functions/string#str-length",
"#str_slice-instance_method": "/documentation/functions/string#str-slice",
"#to_lower_case-instance_method": "/documentation/functions/string#to-lower-case",
"#to_upper_case-instance_method": "/documentation/functions/string#to-upper-case",
"#transparentize-instance_method": "/documentation/functions/color#transparentize",
"#type_of-instance_method": "/documentation/functions/meta#type-of",
"#unique_id-instance_method": "/documentation/functions/string#unique-id",
"#unit-instance_method": "/documentation/functions/math#unit",
"#unitless-instance_method": "/documentation/functions/math#unitless",
"#unquote-instance_method": "/documentation/functions/string#unquote",
"#variable_exists-instance_method": "/documentation/functions/meta#variable-exists",
"#zip-instance_method": "/documentation/functions/list#zip"
"#index-instance_method": "/documentation/modules/list#index",
"#inspect-instance_method": "/documentation/modules/meta#inspect",
"#invert-instance_method": "/documentation/modules/color#invert",
"#is_bracketed-instance_method": "/documentation/modules/list#is-bracketed",

Choose a reason for hiding this comment

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

Line is too long.

"#is_superselector-instance_method": "/documentation/modules/selector#is-superselector",

Choose a reason for hiding this comment

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

Line is too long.

"#join-instance_method": "/documentation/modules/list#join",
"#keywords-instance_method": "/documentation/modules/meta#keywords",
"#length-instance_method": "/documentation/modules/list#length",
"#lighten-instance_method": "/documentation/modules/color#lighten",
"#lightness-instance_method": "/documentation/modules/color#lightness",
"#list_separator-instance_method": "/documentation/modules/list#separator",

Choose a reason for hiding this comment

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

Line is too long.

"#map_get-instance_method": "/documentation/modules/map#get",
"#map_has_key-instance_method": "/documentation/modules/map#has-key",
"#map_keys-instance_method": "/documentation/modules/map#keys",
"#map_merge-instance_method": "/documentation/modules/map#merge",
"#map_remove-instance_method": "/documentation/modules/map#remove",
"#map_values-instance_method": "/documentation/modules/map#values",
"#max-instance_method": "/documentation/modules/math#max",
"#min-instance_method": "/documentation/modules/math#min",
"#mix-instance_method": "/documentation/modules/color#mix",
"#mixin_exists-instance_method": "/documentation/modules/meta#mixin-exists",

Choose a reason for hiding this comment

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

Line is too long.

"#nth-instance_method": "/documentation/modules/list#nth",
"#opacify-instance_method": "/documentation/modules/color#opacify",
"#opacity-instance_method": "/documentation/modules/color#opacity",
"#percentage-instance_method": "/documentation/modules/math#percentage",
"#quote-instance_method": "/documentation/modules/string#quote",
"#random-instance_method": "/documentation/modules/math#random",
"#red-instance_method": "/documentation/modules/color#red",
"#rgb-instance_method": "/documentation/modules/color#rgb",
"#rgba-instance_method": "/documentation/modules/color#rgba",
"#round-instance_method": "/documentation/modules/math#round",
"#saturate-instance_method": "/documentation/modules/color#saturate",
"#saturation-instance_method": "/documentation/modules/color#saturation",
"#scale_color-instance_method": "/documentation/modules/color#scale",
"#selector_append-instance_method": "/documentation/modules/selector#append",

Choose a reason for hiding this comment

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

Line is too long.

"#selector_extend-instance_method": "/documentation/modules/selector#extend",

Choose a reason for hiding this comment

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

Line is too long.

"#selector_nest-instance_method": "/documentation/modules/selector#nest",
"#selector_parse-instance_method": "/documentation/modules/selector#parse",

Choose a reason for hiding this comment

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

Line is too long.

"#selector_replace-instance_method": "/documentation/modules/selector#replace",

Choose a reason for hiding this comment

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

Line is too long.

"#selector_unify-instance_method": "/documentation/modules/selector#unify",

Choose a reason for hiding this comment

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

Line is too long.

"#set-instance_method": "/documentation/modules/list#set",
"#simple_selectors-instance_method": "/documentation/modules/selector#simple-selectors",

Choose a reason for hiding this comment

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

Line is too long.

"#str_index-instance_method": "/documentation/modules/string#index",
"#str_insert-instance_method": "/documentation/modules/string#insert",
"#str_length-instance_method": "/documentation/modules/string#length",
"#str_slice-instance_method": "/documentation/modules/string#slice",
"#to_lower_case-instance_method": "/documentation/modules/string#to-lower-case",

Choose a reason for hiding this comment

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

Line is too long.

"#to_upper_case-instance_method": "/documentation/modules/string#to-upper-case",

Choose a reason for hiding this comment

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

Line is too long.

"#transparentize-instance_method": "/documentation/modules/color#transparentize",

Choose a reason for hiding this comment

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

Line is too long.

"#type_of-instance_method": "/documentation/modules/meta#type-of",
"#unique_id-instance_method": "/documentation/modules/string#unique-id",
"#unit-instance_method": "/documentation/modules/math#unit",
"#unitless-instance_method": "/documentation/modules/math#is-unitless",
"#unquote-instance_method": "/documentation/modules/string#unquote",
"#variable_exists-instance_method": "/documentation/modules/meta#variable-exists",

Choose a reason for hiding this comment

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

Line is too long.

"#zip-instance_method": "/documentation/modules/list#zip"
};

var redirect = redirects[window.location.hash];
if (redirect) window.location.href = redirect;

Choose a reason for hiding this comment

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

Expected '{' and instead saw 'window'.

} else if (window.location.pathname == "/documentation/modules/color") {
var redirects = {
"#rgb": "/documentation/modules#rgb",
"#rgba": "/documentation/modules#rgba",
"#hsl": "/documentation/modules#hsl",
"#hsla": "/documentation/modules#hsla"
};

var redirect = redirects[window.location.hash];
Expand Down
20 changes: 16 additions & 4 deletions source/code-snippets/_example-advanced-nesting.html.md.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
For example, suppose you want to write a selector that matches the outer
selector *and* an element selector. You could write a mixin like this one that
uses the [`selector-unify()` function][] to combine `&` with a user's selector.
uses the [`selector.unify()` function][] to combine `&` with a user's selector.

[`selector-unify()` function]: ../functions/selector#selector-unify
[`selector.unify()` function]: ../modules/selector#unify

<% example do %>
@use "sass:selector";

@mixin unify-parent($child) {
@at-root #{selector-unify(&, $child)} {
@at-root #{selector.unify(&, $child)} {
@content;
}
}
Expand All @@ -20,8 +22,10 @@ uses the [`selector-unify()` function][] to combine `&` with a user's selector.
}
}
===
@use "sass:selector";

@mixin unify-parent($child)
@at-root #{selector-unify(&, $child)}
@at-root #{selector.unify(&, $child)}
@content


Expand All @@ -32,4 +36,12 @@ uses the [`selector-unify()` function][] to combine `&` with a user's selector.

@include unify-parent("select")
/* ...
===
.wrapper input.field {
/* ... */
}

.wrapper select.field {
/* ... */
}
<% end %>
Loading