-
Notifications
You must be signed in to change notification settings - Fork 394
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
Build time tooltips #1334
Build time tooltips #1334
Conversation
This lets it be used at build time without transpilation. We could also use JSON, but this change is smaller and easier.
This is similar to the recent Community refactor. A model parses the raw JS glossary data, walks the tree parsing all Markdown to HTML, then exposes the resulting processed glossary via GraphQL and a useStaticQuery hook. The `Tooltip` components that used to use `react-markdown` now use `dangerouslySetInnerHTML` to consume description data.
Remark dislikes special elements broken across lines halfway, so this is needed to get the link processsed.
Thanks for finding that! |
You are out of testsChoose a plan to resume monitoring your Sites and Pull Requests. If you need help, check the Manage Your Plan and Test Usage guide. |
@rogermparent still not fixed for me, deployment problem? |
It's fixed on my local machine, so it looks a lot like a cache issue. Maybe it's part of my |
YAML is much friendlier than JSON for embedded multiline string content, and with a slight modification to the JSON file loader we can handle them the exact same way and parse the YAML to JSON at build time to serve to the components. With a regular data file instead of a JS module, HMR works for tooltips now (mostly)! We used to have to restart the dev server to update tooltips, and the previous iteration of this branch also had caching issues. This solves that by binding the Glossary data to a file, piggybacking on its `contentDigest`. You still have to refresh the page to update tooltips though, but I think this is more due to how they are implemented with state on the client side. Either way, it's an improvement from before and eliminating the need to restart gets us most of the possible time savings in this regard. - Added YAML support to `json-files` model. I didn't rename it because I think `json-files` more accurately describes how files are parsed into plain JSON than something like `data-files` - Updated Glossary model to use YAML source file - Converted ES5 glossary to YAML - Explicitly add `js-yaml` and run `yarn update` `js-yaml` is used within Gatsby, so it's already installed. However, we get two different versions without an `update`
…ild-time-tooltips
Remark doesn't like breaking specifically between `]` and `(` in a link, but this should be fine.
I changed the Glossary data file to YAML, as it's the data format most friendly to line breaks (as opposed to JSON). All parsing is done at build time, and components still receive the exact same JSON object as before. Doing this instead of using an ES5/6 module also allows for HMR on tooltips. The rest of the implementation doesn't quite allow for it yet, but this change allows us to simply refresh the page to update instead of rebuilding the application. |
@rogermparent good stuff! a few questions:
|
I don't think so- at least our
My custom model does that- it mimics the exact data shape we used previously. I can change it to be any data shape we'd like. Our Tooltip component is currently built with a custom state that expects to consume the all the tooltip data as a JSON blob ahead of time and show tooltips when needed. If we split the data into multiple nodes we'll either have to recombine it for the components or change the components to accept piecemeal data. At this point, the way we store Glossary entries is 100% writer's preference- we can take anything and transform it into the JSON that the frontend components expect during build time for no runtime penalty. For example, we could have a separate |
it sound reasonable to me. It's easier for writers, we don't need to add prettier, we don't need converters. WDYT? |
Sounds good to me! I'll adapt this branch to that data shape once it deploys with the current one. I had to sort out some merge issues with master. |
I got a good deploy with the original setup on Heroku manually a while ago, though it doesn't show here. Primarily, we need to figure out what directory to use for glossary entries and where we want the glossary entries to show up (glossary page, tooltips, and optionally individual pages for entries). I'll explain a few common routes, but we could really do anything here so feel free to make a suggestion for something that I don't describe below. content/docs/glossaryIt's right next to the rest of the docs. Entries will be picked up by the DocsPage Model by default, creating pages at To keep glossary entries co-located with docs here, we must either build on these glossary entry pages and turn them into real pages (which is easily done with templates) or suppress them so they only show on the There's also the option of moving the glossary to a directory that isn't picked up by the DocsPage model. content/glossaryStill pretty close to the docs, this folder is still picked up by our |
I just realized that the glossary doesn't seem to have its own page in Either way, that's another design decision- we can either have a glossary page or only use the data for tooltips. |
Excellent stuff @rogermparent !
We never had a stand-alone page for it - see #542
Good question. My thoughts on this: Let's move them into We can make it the first strep of solving the #947 and #542 - we'll have a section under the user guide with multiple pages, each page is a MD file with frontmatter that defines tooltip + some longer description that describes the concept in details. Start expanding the concept descriptions as part of the #947 - btw, could be a good GSoD task /cc @jorgeorpinel @rogermparent @jorgeorpinel WDYT? |
I need to bring that Gatsby child node factory I made in the Community Model into this one and the others- I didn't think of it until the codeclimate complaint. Not necessarily related to this issue, but I think most everything's taken care of so I'll start on this branch and make a new PR if we merge this PR before I'm done with the refactor. |
We no longer use it anywhere.
This simple wrapper was introduced in the Community Model. I'm just using it in the other models now where applicable. `childNodeCreator` makes a function that acts like `createNode`, but adds in the parent ID of the current node calls `createParentChildLink` between the two nodes, and resolves when the prior two tasks do. I invoke the creators in the "parent" models' APIs so the Models that consume them get a nice function for creating child nodes. The consumer API calls that use this helper don't even need to destructure `actions` anymore, as making a child node is their only function most of the time.
@rogermparent it has not been redeployed for some reason? |
@shcheklein That's really weird, I'm not sure what happened there but I triggered a redeploy on Heroku and that fixed it for me. It deployed over the same URL at https://dvc-landing-build-time--fnpeae.herokuapp.com, but GitHub still marks the automatic deploy as inactive. |
It works on the latest auto-deploy! Might've been some sort of caching issue, but unless it shows up again I'm willing to write it off as a fluke. |
@rogermparent thanks! awesome stuff! |
{ | ||
name: 'DVC Project', | ||
match: [ | ||
'DVC project', | ||
'DVC projects', | ||
'project', | ||
'projects', | ||
'DVC repository', | ||
'DVC repositories' | ||
], | ||
desc: ` | ||
Initialized by running \`dvc init\` in the **workspace** (typically in a Git | ||
repository). It will contain the | ||
[\`.dvc/\` directory](/doc/user-guide/dvc-files-and-directories) and | ||
[DVC-files](/doc/user-guide/dvc-file-format) created with commands such as | ||
\`dvc add\` or \`dvc run\`. | ||
` | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops! Thanks for the catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixing it in #1358 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
* cmd ref: update WebDAV remote info per #1187 (comment) * cmd ref: remove WebDAV remote info for #1355 * glossary: add back DVC project per #1334 (review) * Re-add abbrs within details This feature broke at some point in the past and all these were removed. The feature has since been fixed, so these are safe to re-add. * Re-add cache directory in add-files * Change "cache directory" to "cache" We don't have a tooltip match for "cache directory" * Re-add some missed abbrs * Revert grammar change I think I missed the correct context originally when editing it, and committed it because it looked like any other abbr addition. Co-authored-by: Jorge Orpinel <[email protected]>
Fixes #1045
This PR loads Tooltip data into GraphQL at build time, processing the Markdown descriptions into HTML. The components that consumed this data now no longer depend on
react-markdown
, and instead load the build-time HTML content viadangerouslySetInnerHTML
.