Skip to content

Commit

Permalink
Merge branch 'speced:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbhmr authored Nov 3, 2024
2 parents f22e63a + 6cae8cf commit c135b70
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 60 deletions.
2 changes: 1 addition & 1 deletion bikeshed/Spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def printTargets(self) -> None:
def isOpaqueElement(self, el: t.ElementT) -> bool:
if el.tag in self.md.opaqueElements:
return True
if el.get("data-opaque") is not None or el.get("bs-opaque") is not None: # noqa needless-bool
if el.get("data-opaque") is not None or el.get("bs-opaque") is not None: # needless-bool
return True
return False

Expand Down
8 changes: 4 additions & 4 deletions bikeshed/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,12 +693,12 @@ def handleProfile(options: argparse.Namespace) -> None:
root = f'--root="{options.root}"' if options.root else ""
leaf = f'--leaf="{options.leaf}"' if options.leaf else ""
if options.svgFile:
os.system( # noqa s605
f"time python -m cProfile -o stat.prof -m bikeshed -f spec && gprof2dot -f pstats --skew=.0001 {root} {leaf} stat.prof | dot -Tsvg -o {options.svgFile} && rm stat.prof",
os.system(
f"time python -m cProfile -o stat.prof -m bikeshed -f spec && gprof2dot -f pstats --skew=.0001 {root} {leaf} stat.prof | dot -Tsvg -o {options.svgFile} && rm stat.prof", # noqa: S605
)
else:
os.system( # noqa s605
f"time python -m cProfile -o /tmp/stat.prof -m bikeshed -f spec && gprof2dot -f pstats --skew=.0001 {root} {leaf} /tmp/stat.prof | xdot &",
os.system(
f"time python -m cProfile -o /tmp/stat.prof -m bikeshed -f spec && gprof2dot -f pstats --skew=.0001 {root} {leaf} /tmp/stat.prof | xdot &", # noqa: S605
)


Expand Down
2 changes: 1 addition & 1 deletion bikeshed/doctypes/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def looselyMatch(self, rawStatus: str) -> bool:
orgName, statusName = utils.splitOrg(rawStatus)
if statusName and self.name.upper() != statusName.upper():
return False
if orgName and self.org.name != orgName.upper(): # noqa needless-bool
if orgName and self.org.name != orgName.upper(): # needless-bool
return False
return True

Expand Down
4 changes: 2 additions & 2 deletions bikeshed/h/dom.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def validUrlUnit(char: str) -> bool:
else:
if 0xD800 <= c <= 0xDFFF or 0xFDD0 <= c <= 0xFDEF:
return False
if (c % 0xFFFF) in [0xFFFE, 0xFFFF]: # noqa needless-bool
if (c % 0xFFFF) in [0xFFFE, 0xFFFF]: # needless-bool
# Last two bytes are FFFE or FFFF
return False
return True
Expand Down Expand Up @@ -737,7 +737,7 @@ def isOddNode(node: t.Any) -> bool:
# Something other than an element node or string.
if isinstance(node, str):
return False
if isElement(node): # noqa needless-bool
if isElement(node): # needless-bool
return False
return True

Expand Down
30 changes: 22 additions & 8 deletions bikeshed/h/parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
ParserNode,
RawElement,
RawText,
SafeText,
SelfClosedTag,
StartTag,
escapeAttr,
Expand Down Expand Up @@ -704,18 +705,31 @@ def parseCSSProduction(s: Stream, start: int) -> Result[list[ParserNode]]:
if text is None:
m.die("Saw the start of a CSS production (like <<foo>>), but couldn't find the end.", lineNum=s.loc(start))
return Result.fail(start)
if "\n" in text:
elif "\n" in text:
m.die(
"Saw the start of a CSS production (like <<foo>>), but couldn't find the end on the same line.",
lineNum=s.loc(start),
)
return Result.fail(start)
if "<" in text or ">" in text:
m.die(
"It seems like you wrote a CSS production (like <<foo>>), but there's more markup inside of it, or you didn't close it properly.",
lineNum=s.loc(start),
)
return Result.fail(start)
elif "<" in text or ">" in text:
# Allow <<boolean [<<foo>>]>>
if "[" in text:
endOfArg = s.skipTo(textEnd, "]").i
newTextEnd = s.skipTo(endOfArg, ">>").i
if endOfArg == textEnd or newTextEnd == endOfArg: # noqa: PLR1714
m.die(
"It seems like you wrote a CSS production with an argument (like <<foo [<<bar>>]>>), but either included more [] in the argument, or otherwise messed up the syntax.",
lineNum=s.loc(start),
)
return Result.fail(start)
textEnd = newTextEnd
text = s[textStart:textEnd]
else:
m.die(
"It seems like you wrote a CSS production (like <<foo>>), but there's more markup inside of it, or you didn't close it properly.",
lineNum=s.loc(start),
)
return Result.fail(start)
nodeEnd = textEnd + 2

startTag = StartTag(
Expand All @@ -724,7 +738,7 @@ def parseCSSProduction(s: Stream, start: int) -> Result[list[ParserNode]]:
tag="fake-production-placeholder",
attrs={"bs-autolink-syntax": s[start:nodeEnd], "class": "production", "bs-opaque": ""},
).finalize()
contents = RawText(
contents = SafeText(
line=s.line(textStart),
endLine=s.line(textEnd),
text=text,
Expand Down
4 changes: 2 additions & 2 deletions bikeshed/h/parser/preds.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,15 @@ def isTagnameChar(ch: str) -> bool:
return True
if 0xFDF0 <= cp <= 0xFFFD:
return True
if 0x10000 <= cp <= 0xEFFFF: # noqa needless-bool
if 0x10000 <= cp <= 0xEFFFF: # needless-bool
return True
return False


def isAttrNameChar(ch: str) -> bool:
if len(ch) != 1:
return False
if isWhitespace(ch) or ch in "/<>=\"'" or ord(ch) == 0: # noqa needless-bool
if isWhitespace(ch) or ch in "/<>=\"'" or ord(ch) == 0: # needless-bool
return False
return True

Expand Down
2 changes: 1 addition & 1 deletion bikeshed/h/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def needsEndTag(self, el: t.ElementT, nextEl: Nodes | None = None) -> bool:
if el.tag in ["dt", "dd"]:
if nextEl is None:
return False
if self.isElement(nextEl) and nextEl.tag in ["dt", "dd"]: # noqa needless-bool
if self.isElement(nextEl) and nextEl.tag in ["dt", "dd"]: # needless-bool
return False
return True
return False
Expand Down
2 changes: 1 addition & 1 deletion bikeshed/semver.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2.1
4.2.3
29 changes: 25 additions & 4 deletions bikeshed/shorthands/oldShorthands.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,20 @@ def transformProductionPlaceholders(doc: t.SpecT) -> None:
""",
re.X,
)
typeWithArgsRe = re.compile(
r"""
^(?:(\S*)/)?
(\S+)
\s*\[([^\]]*)\]\s*$
""",
re.X,
)
for el in h.findAll("fake-production-placeholder", doc):
addLineNumber(el)
text = h.textContent(el)
h.clearContents(el)
match = propdescRe.match(text)
lt = text
match = propdescRe.match(lt)
if match:
linkFor, lt, linkType = match.groups()
if linkFor == "":
Expand All @@ -55,7 +64,7 @@ def transformProductionPlaceholders(doc: t.SpecT) -> None:
el.set("for", linkFor)
el.text = "<'" + lt + "'>"
continue
match = funcRe.match(text)
match = funcRe.match(lt)
if match:
el.tag = "a"
el.set("data-link-type", "function")
Expand All @@ -64,7 +73,7 @@ def transformProductionPlaceholders(doc: t.SpecT) -> None:
el.set("for", match.group(1))
el.text = "<" + match.group(2) + ">"
continue
match = atruleRe.match(text)
match = atruleRe.match(lt)
if match:
el.tag = "a"
el.set("data-link-type", "at-rule")
Expand All @@ -73,7 +82,7 @@ def transformProductionPlaceholders(doc: t.SpecT) -> None:
el.set("for", match.group(1))
el.text = "<" + match.group(2) + ">"
continue
match = typeRe.match(text)
match = typeRe.match(lt)
if match:
for_, term, rangeStart, rangeEnd = match.groups()
el.tag = "a"
Expand All @@ -98,6 +107,18 @@ def transformProductionPlaceholders(doc: t.SpecT) -> None:
else:
el.text = f"<{term}>"
continue
match = typeWithArgsRe.match(lt)
if match:
for_, term, arg = match.groups()
el.tag = "a"
el.set("data-lt", f"<{term}>")
el.set("data-link-type", "type")
if "<<" in arg:
arg = arg.replace("<<", "<").replace(">>", ">")
el.text = f"<{term}[{arg}]>"
if for_ is not None:
el.set("for", for_)
continue
m.die(f"Shorthand <<{text}>> does not match any recognized shorthand grammar.", el=el)
el.tag = "span"
el.text = el.get("bs-autolink-syntax")
Expand Down
2 changes: 1 addition & 1 deletion bikeshed/spec-data/readonly/bikeshed-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Bikeshed version 44fb9b41e, updated Mon Oct 21 15:57:35 2024 -0700
Bikeshed version 9e4e5f0f6, updated Mon Oct 28 14:51:59 2024 -0700
2 changes: 1 addition & 1 deletion bikeshed/stylescript/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def insertable(self, allowList: t.BoolSet) -> bool:
return False
if self.data is None:
return True
if self.data[1]: # noqa needless-bool
if self.data[1]: # needless-bool
return True
return False

Expand Down
21 changes: 18 additions & 3 deletions docs/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,8 @@ There are several additional optional keys:
You can set a different `crossorigin` value manually on the element,
or skip the element entirely by putting `nocrossorigin` on it or an ancestor.
* <dfn>WPT Path Prefix</dfn> is a partial URL path
that specifies a common path prefix for all of the tests in your <{wpt}> elements.
that specifies a default path prefix for all of the tests in your <{wpt}> elements.
(This can be overridden on an individual <{wpt}> element.)
* <dfn>WPT Display</dfn> takes the values "none", "closed", "open", or "inline",
and specifies whether and how <{wpt}> elements display anything in the output document.
* <dfn>Tracking Vector Class</dfn> is the HTML `class` attribute value used on the link inserted in elements annotated with the `tracking-vector` attribute.
Expand Down Expand Up @@ -3859,9 +3860,12 @@ pointing to the test covering some nearby text.
If all or most of your tests have a common path prefix,
you can specify it in [=WPT Path Prefix=] metadata,
and then leave it off of all the individual test lines.
This also triggers Bikeshed to complain if it knows of any tests under that prefix
that don't show up in your spec.

An explicit <dfn element-attr for="wpt, wpt-rest">pathprefix</dfn> attribute
can also provide the path prefix,
and will override the metadata if specified.
can also provide the path prefix for a single <{wpt}> block,
overriding the metadata if specified.

<div class=example>
If the preceding example used [=WPT Path Prefix=],
Expand All @@ -3882,6 +3886,17 @@ and will override the metadata if specified.
no-foo-when-no-bar.html
</wpt>
</xmp>

Alternately, the path prefix could be indicated just on the one block:

<xmp highlight=html>
Implementations must FOO whenever they would also BAR.

<wpt pathprefix="/foo-spec/">
foo-whenever-you-bar.html
no-foo-when-no-bar.html
</wpt>
</xmp>
</div>

For debugging purposes,
Expand Down
Loading

0 comments on commit c135b70

Please sign in to comment.