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

WIP: snapshot support #70

Merged
merged 8 commits into from
May 29, 2018
Merged

WIP: snapshot support #70

merged 8 commits into from
May 29, 2018

Conversation

annevk
Copy link
Member

@annevk annevk commented May 15, 2018

This makes some progress on snapshots, but it's a lot of effort...

annevk added a commit to whatwg/html-build that referenced this pull request May 15, 2018
annevk added a commit to whatwg/html that referenced this pull request May 15, 2018
See whatwg/html-build#151 and whatwg/wattsi#70.

We should probably change wattsi such that everything annotated w-nohtml does not always have to be annotated with w-nosnap...
@annevk
Copy link
Member Author

annevk commented May 15, 2018

On top of this we'd have to support yet another variant that only builds a single singlepage document with "Review Draft" relevant output. I'm not sure I want to put in the effort though since this took me quite a while and I'm getting nowhere fast.

@annevk
Copy link
Member Author

annevk commented May 15, 2018

cc @domenic

This makes some progress on snapshots, but it's a lot of effort...
@annevk
Copy link
Member Author

annevk commented May 15, 2018

This setup requires annotating most w-nohtml annotations in HTML also with w-nosnap. It would be nice to improve on that. I think we should introduce w-dev as a way of omitting things when Variant <> vDEV.

As for Review Drafts, my idea was that we would support a seventh argument to the wattsi invocation that would take care of that. Ideally as a modification on top of the vSnap variant.

annevk added a commit to whatwg/html-build that referenced this pull request May 16, 2018
src/wattsi.pas Outdated
Scratch := Default(Rope);
Scratch.Append('https://github.com/whatwg/html/commit/');
Scratch.Append(@SourceGitSHA[1], Length(SourceGitSHA));
Element.SetAttributeDestructively('href', Scratch);
Copy link
Member Author

Choose a reason for hiding this comment

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

This bit here doesn't work. End up with a bunch of wrong bytes in the final output. Elsewhere I could work around combining an AnsiString with some other type of string, but that doesn't work when setting attributes. I'd appreciate some help.

cc @Hixie @sideshowbarker

@sideshowbarker
Copy link
Contributor

sideshowbarker commented May 17, 2018

+            Element.SetAttributeDestructively('href', Scratch);

This bit here doesn't work. End up with a bunch of wrong bytes in the final output. Elsewhere I could work around combining an AnsiString with some other type of string, but that doesn't work when setting attributes.

0751161 is a workaround for now. It’s not the right way but it gets the job done as far as I can tell, and I figured it’s better to go ahead and push this to the branch for testing at least..

But if we want to have the snapshot stuff working sooner rather than later — and as long as the rest of it other than this is working — then it wouldn’t be harmful to go ahead and merge this to master as-is and plan a follow-up commit for later to do this the right way.

As far as what’s actually the right way: In working on previous patches, I’ve run into the same problem before when trying to deal with using the Rope stuff and with some of the related functions expecting constants instead of mutable variables. However right now I can’t remember exactly how I ended up dealing with it (or avoiding it) in those other cases. But I can probably (re)figure it out by tomorrow or so. Or else maybe if @Hixie can take a quick look it may be obvious to him what we should do instead.

But anyway as I said, I think 0751161 gets us what we need for now.

{$IFDEF TIMINGS} Writeln('Elapsed time: ', MillisecondsBetween(StartTime, Now()), 'ms'); {$ENDIF}
// output...
if (Variant <> vDEV) then
for Variant in TVariants do
Copy link
Member Author

Choose a reason for hiding this comment

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

There's some copying of documents earlier on that also does that for all variants. I suppose we could add additional branching there too to save a bit of a processing time.

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

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

This seems pretty solid to me, although I am mostly judging on results...

This reverts 0751161 in favor of using Rope.Append in roughly the same
sort of way it’s used in similar cases in the source.
@sideshowbarker
Copy link
Contributor

sideshowbarker commented May 19, 2018

+            Scratch.Append('https://….com/whatwg/html/commit/');
+            Scratch.Append(@SourceGitSHA[1], Length(SourceGitSHA));
+            Element.SetAttributeDestructively('href', Scratch);

6d066f9 (re)fixes that — and unlike the previous hack I pushed in 0751161, 6d066f9 does it in the right way. Or it’s at least something closer to the right way (where “right” is basically just however @Hixie would have done it himself…).

I got there after spending time looking back at the Rope sources and remembering where I ran into problems with it myself before. And that’s specifically in the fact that if you give Scratch.Append(…) a string, it must be a “short” string — because if you don’t, it won’t work as expected.

As far as what doesn’t work as expected, I think usually you end up with unexpected bytes in the output (because I guess some overflow has happened and you start getting stuff from other memory addresses) — but I think sometimes it also just causes a fatal error and “Access violation” message.

Anyway, regardless, in any case it always leads to breakage at runtime without a clear error message about what the actual specific cause is.

What it ideally should do instead is, fail to compile to begin with — or if not that, at least generate a fatal error at runtime with a specific message saying, “String must be no longer than NN characters.“

As far as what the code considers “short”: It appears to be platform-dependent but it seems in my environment at least (and maybe in all 64-bit environments), it’s 11 characters or less.

So what you what you need to do instead is, assign the string to a variable and then give Scratch.Append(…) a pointer to that. Which is what 6d066f9 does.

src/wattsi.pas Outdated
if (not Split(Documents[Variant], BigTOC, OutputDirectory + '/multipage-' + kSuffixes[Variant] + '/')) then
raise EAbort.Create('Could not split specification');
{$IFDEF TIMINGS} Writeln('Elapsed time: ', MillisecondsBetween(StartTime, Now()), 'ms'); {$ENDIF}
Result := True;
Copy link
Member Author

Choose a reason for hiding this comment

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

Should this move down again?

@annevk
Copy link
Member Author

annevk commented May 22, 2018

Commit message:

Add support for Commit Snapshots and Review Drafts

This enables singlepage Commit Snapshots and Review Drafts with the appropriate annotations, while keeping most of the input for them in whatwg/html and whatwg/html-build.

This depends on https://github.com/whatwg/html-build/pull/151 and https://github.com/whatwg/html/pull/3689 landing around the same time.

@annevk
Copy link
Member Author

annevk commented May 22, 2018

I fixed my own two nits, although avoiding additional cloning comes at a bit of additional code.

Copy link
Contributor

@sideshowbarker sideshowbarker left a comment

Choose a reason for hiding this comment

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

Tested and reviewed and all LGTM

annevk added a commit to whatwg/html-build that referenced this pull request May 29, 2018
See whatwg/meta#92 for details. And whatwg/wattsi#70 and whatwg/html#3689 for changes that are needed as well.
annevk added a commit to whatwg/html that referenced this pull request May 29, 2018
See whatwg/meta#92 for details. And whatwg/html-build#151 and whatwg/wattsi#70 for changes that are needed as well.
alice pushed a commit to alice/html that referenced this pull request Jan 8, 2019
See whatwg/meta#92 for details. And whatwg/html-build#151 and whatwg/wattsi#70 for changes that are needed as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants