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

add tool command for rendering/removing macros #2955

Merged
merged 1 commit into from
Mar 11, 2021
Merged

add tool command for rendering/removing macros #2955

merged 1 commit into from
Mar 11, 2021

Conversation

escattone
Copy link
Contributor

@escattone escattone commented Feb 16, 2021

Adds a new yarn tool macros command to either render or remove one or more macros from a tree of documents.

@escattone
Copy link
Contributor Author

Here are some examples:

Rendering-out cssxref macro (skipping when un-fixable flaws)

rjohnson-44864:yari rjohnson$(maws_profile)$ yarn tool macros render en-us/web/css/transform cssxref
yarn run v1.22.5
$ node tool/cli.js macros render en-us/web/css/transform cssxref
render the macro(s) "cssxref" within content folder(s) matching "en-us/web/css/transform"
/Users/rjohnson/repos/content/files/en-us/web/css/transform-box/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/matrix()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/matrix3d()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/perspective()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/rotate()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/rotate3d()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/rotatex()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/rotatey()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/rotatez()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/scale()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/scale3d()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/scalex()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/scaley()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/scalez()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/skew()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/skewx()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/skewy()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/translate()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/translate3d()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/translatex/index.html:
  skipping, has 1 non-fixable flaw(s) (MacroBrokenLinkError)
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/translatey()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/translatez()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-origin/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-style/index.html:
  no change
/Users/rjohnson/repos/content/files/en-us/web/css/transform/index.html:
  fixing 1 fixable flaw(s) before proceeding:
    {{cssxref("transform-function/perspective", "perspective()")}} --> {{cssxref("transform-function/perspective()", "perspective()")}}
  modified
modified: 24 | no-change: 1 | skipped: 1 | total: 26
✨  Done in 8.91s.

Rendering-out cssxref macro (forcing render when un-fixable flaws)

rjohnson-44864:yari rjohnson$(maws_profile)$ yarn tool macros render en-us/web/css/transform cssxref -f
yarn run v1.22.5
$ node tool/cli.js macros render en-us/web/css/transform cssxref -f
render the macro(s) "cssxref" within content folder(s) matching "en-us/web/css/transform"
/Users/rjohnson/repos/content/files/en-us/web/css/transform-box/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/matrix()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/matrix3d()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/perspective()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/rotate()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/rotate3d()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/rotatex()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/rotatey()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/rotatez()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/scale()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/scale3d()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/scalex()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/scaley()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/scalez()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/skew()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/skewx()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/skewy()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/translate()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/translate3d()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/translatex/index.html:
  ignoring 1 non-fixable flaw(s) (MacroBrokenLinkError)
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/translatey()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-function/translatez()/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-origin/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/web/css/transform-style/index.html:
  no change
/Users/rjohnson/repos/content/files/en-us/web/css/transform/index.html:
  fixing 1 fixable flaw(s) before proceeding:
    {{cssxref("transform-function/perspective", "perspective()")}} --> {{cssxref("transform-function/perspective()", "perspective()")}}
  modified
modified: 25 | no-change: 1 | skipped: 0 | total: 26
✨  Done in 8.94s.

Removing fx_minversion_header macro

rjohnson-44864:yari rjohnson$(maws_profile)$ yarn tool macros remove en-us/mozilla fx_minversion_header
...
/Users/rjohnson/repos/content/files/en-us/mozilla/thunderbird/autoconfiguration/fileformat/definition/index.html:
  no change
/Users/rjohnson/repos/content/files/en-us/mozilla/thunderbird/autoconfiguration/fileformat/howto/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/mozilla/thunderbird/autoconfiguration/fileformat/index.html:
  no change
/Users/rjohnson/repos/content/files/en-us/mozilla/thunderbird/autoconfiguration/index.html:
  modified
/Users/rjohnson/repos/content/files/en-us/mozilla/virtualenv/index.html:
  modified
modified: 560 | no-change: 739 | skipped: 0 | total: 1299
✨  Done in 13.63s.

@Elchi3
Copy link
Member

Elchi3 commented Feb 17, 2021

I'm very excited about this PR, Ryan! 🚀

Copy link
Contributor

@fiji-flo fiji-flo left a comment

Choose a reason for hiding this comment

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

Looks good. I'd suggest we move most of the logic from tool to content to make it easier to reuse.

@peterbe peterbe marked this pull request as draft February 22, 2021 19:49
@peterbe
Copy link
Contributor

peterbe commented Feb 22, 2021

@escattone and I chatted about this. Some more thoughts needs to go into whether we make this part of the "core Yari API" (e.g. moving it into the content directory). Or, perhaps we treat it as a hacky script that we use for a couple of weeks and then throw away.

@escattone
Copy link
Contributor Author

@fiji-flo Are you OK with landing this as is (so we can start using it for our Q1 goals), and refactoring later when we find a use case for reusing it?

@fiji-flo
Copy link
Contributor

fiji-flo commented Mar 4, 2021

@escattone sure

@fiji-flo
Copy link
Contributor

fiji-flo commented Mar 4, 2021

Just to be aware of: it'll apply some implicit formatting via cheerio like converting a   (that's a \u{a0}) into   and changes line breaks.

Nothing to worry about but the modified might be misleading.

@escattone escattone marked this pull request as ready for review March 10, 2021 21:19
@escattone escattone removed the request for review from peterbe March 11, 2021 23:10
@escattone escattone merged commit 83cf627 into mdn:main Mar 11, 2021
@escattone escattone deleted the render-remove-macro-tool branch March 11, 2021 23:11
wbamberg pushed a commit to wbamberg/yari that referenced this pull request Mar 15, 2021
* upstream/main: (164 commits)
  skip empty srcs for safe iframe srcs (mdn#3216)
  correct code comment (mdn#3223)
  build(deps): bump ahmadnassri/action-dependabot-auto-merge (mdn#3197)
  build(deps-dev): bump @types/react-dom from 17.0.1 to 17.0.2 (mdn#3164)
  create a whatsdeployed.json for translated-content too (mdn#3221)
  avoid double-slash redirects (mdn#3222)
  build(deps): bump image-size from 0.9.4 to 0.9.5 (mdn#3214)
  build(deps): bump boto3 from 1.17.22 to 1.17.26 in /deployer (mdn#3212)
  Fix our auto-merge workflow (mdn#3218)
  build(deps-dev): bump ts-loader from 8.0.17 to 8.0.18 (mdn#3208)
  disable lighthouse PR check unless relevant changes (mdn#3203)
  hide toolbar for frozen locales (mdn#3213)
  build(deps): bump is-svg from 4.2.1 to 4.2.2 (mdn#3209)
  build(deps): bump @mdn/browser-compat-data from 3.1.3 to 3.2.0 (mdn#3210)
  downloading external images for translated-content (mdn#3207)
  add active locales (mdn#3201)
  add tool command for rendering/removing macros (mdn#2955)
  unsafe html should be a breaking flaw (mdn#3192)
  open editor for translated content (mdn#3196)
  add fundamental redirects for /en-US/Security/CSP (mdn#3200)
  ...
peterbe pushed a commit to peterbe/yari that referenced this pull request Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants