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

cuelang.org: preprocessor: make examples' files available in a repo #2900

Open
jpluscplusm opened this issue Feb 8, 2024 · 2 comments
Open

Comments

@jpluscplusm
Copy link
Collaborator

jpluscplusm commented Feb 8, 2024

Some pages contain named files inside code or upload blocks, and we could make those files available as stand alone, plain text files in a repo.

This would either need to be implemented inside the preprocessor, or authors will need to manually sync content and files.

Purpose

Making these files available would be a low friction way to allow a reader to play with an example's CUE/JSON/YAML files by simply cloning the repo and navigating to the relevant page's directory.

Considerations

Which repo?

If we were to commit the files into cue-lang/cuelang.org, this would have several advantages:

  • files rendered and committed as part of the standard document author process, without any need to set up cross-repo commits to /another/ repo (e.g. in CI)
  • files would be automatically checked by the check-if-working-tree-is-clean CI test

The only disadvantages I can see are that the cue-lang/cuelang.org repo's size would grow a little faster on each (example-altering) change; and that the repo that the inquisitive reader would need to download would be a bit larger than strictly needed, as they'd necessarily pull down the entire site contents and not just the plain text example files. However, both of these size concerns are pretty trivial.

Suggestion: include the files in cue-lang/cuelang.org in the same commit that introduces/modifies the markdown source of the files.

Where, in the cue-lang/cuelang.org repo?

Whilst we could place the example files alongside the content they're sourced from, we'd probably want to place them in a sub-directory of the content directory so that the user's cue commands wouldn't interact with the content directory's site.cue site package, and so that the user could simply copy cue commands from the the on-page examples and have them work without modification. How this putative content/docs/howto/foo-a-bar/examples/ directory would pass through the Hugo processing, however, is not yet known. Would Hugo try to render a page under that path? Or complain about there not being a renderable source file?

However, instead of using the content directory as the root for the example files, we could place the example files inside a dedicated directory hierarchy, with a structure mirroring the URL paths that readers see on the front end.

Furthermore, if we're clever about the example files' location, then we can achieve both this issue's goal and give ourselves a mechanism for (later) linking to the files via HTTP.

If we use Hugo's static files union-fs-like system, we can place the files in scope for the Hugo build whilst also leaving them isolated on disk for cue users. We can even instantiate a top-level symlink directory in the repo (examples) for cue users to experiment with, as is demonstrated in this CL, simultaneously making this file's URL available for later on-page linkage if we so choose. (The symlink has to be this way round, examples->hugo/examples, as Hugo forbids the other way round)

Suggestion: serialise into hugo/examples and symlink examples into there.

code: overlapping filenames

code blocks are evaluated by the preprocessor in isolation from one another, meaning that multiple code blocks can contain the same filename. How should such a situation be serialised?

script: mutable file content over the course of the page

script blocks build on the context of preceding script and upload blocks. There can be multiple upload blocks for the same (updated) file, and a script block can create, update and delete files. How should a multi-step script's fake filesystem get serialised? Once for each step? After the last step?

Rendering

Nothing on-page, yet. Perhaps a single page should explain that these files exist, but nothing needs changing on the preprocessor's pages emitted into the hugo directory.

@myitcv
Copy link
Member

myitcv commented Feb 8, 2024

I think the main suggestion discussed on the call was making these files available in a GitHub repo. So let's discuss how that might work first.

@jpluscplusm jpluscplusm changed the title Make examples available as discrete files Make examples' files available in a repo Feb 12, 2024
cueckoo referenced this issue in cue-lang/cuelang.org Feb 12, 2024
This is a demo for cue-lang/docs-and-content#57.

Preview-Path: /docs/howto/use-encoding-base64-decode/file.cue
Signed-off-by: Jonathan Matthews <[email protected]>
Change-Id: I86a5d291dc7e8eca58933c4a0ea1e1745ff83441
cueckoo referenced this issue in cue-lang/cuelang.org-trybot Feb 12, 2024
This is a demo for cue-lang/docs-and-content#57.

Preview-Path: /docs/howto/use-encoding-base64-decode/file.cue
Signed-off-by: Jonathan Matthews <[email protected]>
Change-Id: I86a5d291dc7e8eca58933c4a0ea1e1745ff83441
Dispatch-Trailer: {"type":"trybot","CL":1176769,"patchset":1,"ref":"refs/changes/69/1176769/1","targetBranch":"alpha"}
@myitcv myitcv transferred this issue from cue-lang/docs-and-content Mar 1, 2024
@jpluscplusm jpluscplusm changed the title Make examples' files available in a repo alpha.cuelang.org: preprocessor: make examples' files available in a repo Mar 1, 2024
@jpluscplusm
Copy link
Collaborator Author

I think the main suggestion discussed on the call was making these files available in a GitHub repo. So let's discuss how that might work first.

Now reflected in the initial comment.

@jpluscplusm jpluscplusm changed the title alpha.cuelang.org: preprocessor: make examples' files available in a repo cuelang.org: preprocessor: make examples' files available in a repo Mar 26, 2024
@jpluscplusm jpluscplusm changed the title cuelang.org: preprocessor: make examples' files available in a repo cuelang.org: make examples' files available in a repo Mar 26, 2024
cueckoo pushed a commit to cue-lang/cuelang.org that referenced this issue Mar 28, 2024
This adds a small set of representative examples to the playground,
replacing the current invalid examples.

They are placed in an indicative structure, with the "Introduction"
category being intended to hold examples for the user who landed on the
playground before reading any other part of the site, and the "Tour"
category showing a couple of CUE examples taken directly from the
on-page CUE in docs/tour/.

The Tour category isn't expanded to include all the docs examples, yet,
as both cue-lang/cue#2995 and cue-lang/cue#2900 need resolving to let us
avoid spending a *lot* of time on manual content syncing.

Preview-Path: /play
Signed-off-by: Jonathan Matthews <[email protected]>
Change-Id: I374ee591f767bea3a0e07f29ce7825468661f42f
cueckoo pushed a commit to cue-lang/cuelang.org-trybot that referenced this issue Mar 28, 2024
This adds a small set of representative examples to the playground,
replacing the current invalid examples.

They are placed in an indicative structure, with the "Introduction"
category being intended to hold examples for the user who landed on the
playground before reading any other part of the site, and the "Tour"
category showing a couple of CUE examples taken directly from the
on-page CUE in docs/tour/.

The Tour category isn't expanded to include all the docs examples, yet,
as both cue-lang/cue#2995 and cue-lang/cue#2900 need resolving to let us
avoid spending a *lot* of time on manual content syncing.

Preview-Path: /play
Signed-off-by: Jonathan Matthews <[email protected]>
Change-Id: I374ee591f767bea3a0e07f29ce7825468661f42f
Dispatch-Trailer: {"type":"trybot","CL":1188421,"patchset":1,"ref":"refs/changes/21/1188421/1","targetBranch":"master"}
cueckoo pushed a commit to cue-lang/cuelang.org that referenced this issue Mar 28, 2024
This adds a small set of representative examples to the playground,
replacing the current invalid examples.

They are placed in an indicative structure, with the "Introduction"
category being intended to hold examples for the user who landed on the
playground before reading any other part of the site, and the "Tour"
category showing a couple of CUE examples taken directly from the
on-page CUE in docs/tour/.

The Tour category isn't expanded to include all the docs examples, yet,
as both cue-lang/cue#2995 and cue-lang/cue#2900 need resolving to let us
avoid spending a *lot* of time on manual content syncing.

Formatting notes for as&when the examples are expanded, and if their
generation is automated:

- Because cue-lang/cue#722 also strikes the playground ("top-level
  comments are indented") when the playground's default of "cue eval" is
  selected, care has been taken to make sure that comments are used that
  don't trigger this bug (as it looks pretty poor for predefined
  examples to have this problem). Some relevant information:
  - only the first comment presented at the top of the "eval" output is
    affected
  - it doesn't affect comments which aren't included in the output, such
    as introductory comments which are separated by a blank line from
    the first field emitted
  - it doesn't affect fields with a struct or list value
  - it only affects single-line comments
  - it can affect a comment that's not the first line of the source, if
    it's attached to any definition of the first field that's present in
    the emitted output

- Including  links from tour-derived examples back to the relevant tour
  page feels like a win, but they need to be split over two comment
  lines or the end of the URL disappears from view. This also has the
  nice effect of pushing the URL to the second line of the editor, which
  makes the "Follow link (ctrl+click)" mouseover popup *not* get
  visually truncated by the top edge of the editor pane.

Preview-Path: /play
Signed-off-by: Jonathan Matthews <[email protected]>
Change-Id: I374ee591f767bea3a0e07f29ce7825468661f42f
cueckoo pushed a commit to cue-lang/cuelang.org-trybot that referenced this issue Mar 28, 2024
This adds a small set of representative examples to the playground,
replacing the current invalid examples.

They are placed in an indicative structure, with the "Introduction"
category being intended to hold examples for the user who landed on the
playground before reading any other part of the site, and the "Tour"
category showing a couple of CUE examples taken directly from the
on-page CUE in docs/tour/.

The Tour category isn't expanded to include all the docs examples, yet,
as both cue-lang/cue#2995 and cue-lang/cue#2900 need resolving to let us
avoid spending a *lot* of time on manual content syncing.

Formatting notes for as&when the examples are expanded, and if their
generation is automated:

- Because cue-lang/cue#722 also strikes the playground ("top-level
  comments are indented") when the playground's default of "cue eval" is
  selected, care has been taken to make sure that comments are used that
  don't trigger this bug (as it looks pretty poor for predefined
  examples to have this problem). Some relevant information:
  - only the first comment presented at the top of the "eval" output is
    affected
  - it doesn't affect comments which aren't included in the output, such
    as introductory comments which are separated by a blank line from
    the first field emitted
  - it doesn't affect fields with a struct or list value
  - it only affects single-line comments
  - it can affect a comment that's not the first line of the source, if
    it's attached to any definition of the first field that's present in
    the emitted output

- Including  links from tour-derived examples back to the relevant tour
  page feels like a win, but they need to be split over two comment
  lines or the end of the URL disappears from view. This also has the
  nice effect of pushing the URL to the second line of the editor, which
  makes the "Follow link (ctrl+click)" mouseover popup *not* get
  visually truncated by the top edge of the editor pane.

Preview-Path: /play
Signed-off-by: Jonathan Matthews <[email protected]>
Change-Id: I374ee591f767bea3a0e07f29ce7825468661f42f
Dispatch-Trailer: {"type":"trybot","CL":1188421,"patchset":2,"ref":"refs/changes/21/1188421/2","targetBranch":"master"}
cueckoo pushed a commit to cue-lang/cuelang.org that referenced this issue Mar 28, 2024
This adds a small set of representative examples to the playground,
replacing the current invalid examples.

They are placed in an indicative structure, with the "Introduction"
category being intended to hold examples for the user who landed on the
playground before reading any other part of the site, and the "Tour"
category showing a couple of CUE examples taken directly from the
on-page CUE in docs/tour/.

The Tour category isn't expanded to include all the docs examples, yet,
as both cue-lang/cue#2995 and cue-lang/cue#2900 need resolving to let us
avoid spending a *lot* of time on manual content syncing.

Formatting notes for as&when the examples are expanded, and if their
generation is automated:

- Because cue-lang/cue#722 also strikes the playground ("top-level
  comments are indented") when the playground's default of "cue eval" is
  selected, care has been taken to make sure that comments are used that
  don't trigger this bug (as it looks pretty poor for predefined
  examples to have this problem). Some relevant information:
  - only the first comment presented at the top of the "eval" output is
    affected
  - it doesn't affect comments which aren't included in the output, such
    as introductory comments which are separated by a blank line from
    the first field emitted
  - it doesn't affect fields with a struct or list value
  - it only affects single-line comments
  - it can affect a comment that's not the first line of the source, if
    it's attached to any definition of the first field that's present in
    the emitted output

- Including links from tour-derived examples back to the relevant tour
  page feels like a win, but they need to be split over two comment
  lines or the end of the URL disappears from view. This also has the
  nice effect of pushing the URL to the second line of the editor, which
  makes the "Follow link (ctrl+click)" mouseover popup *not* get
  visually truncated by the top edge of the editor pane.

Preview-Path: /play
Signed-off-by: Jonathan Matthews <[email protected]>
Change-Id: I374ee591f767bea3a0e07f29ce7825468661f42f
cueckoo pushed a commit to cue-lang/cuelang.org-trybot that referenced this issue Mar 28, 2024
This adds a small set of representative examples to the playground,
replacing the current invalid examples.

They are placed in an indicative structure, with the "Introduction"
category being intended to hold examples for the user who landed on the
playground before reading any other part of the site, and the "Tour"
category showing a couple of CUE examples taken directly from the
on-page CUE in docs/tour/.

The Tour category isn't expanded to include all the docs examples, yet,
as both cue-lang/cue#2995 and cue-lang/cue#2900 need resolving to let us
avoid spending a *lot* of time on manual content syncing.

Formatting notes for as&when the examples are expanded, and if their
generation is automated:

- Because cue-lang/cue#722 also strikes the playground ("top-level
  comments are indented") when the playground's default of "cue eval" is
  selected, care has been taken to make sure that comments are used that
  don't trigger this bug (as it looks pretty poor for predefined
  examples to have this problem). Some relevant information:
  - only the first comment presented at the top of the "eval" output is
    affected
  - it doesn't affect comments which aren't included in the output, such
    as introductory comments which are separated by a blank line from
    the first field emitted
  - it doesn't affect fields with a struct or list value
  - it only affects single-line comments
  - it can affect a comment that's not the first line of the source, if
    it's attached to any definition of the first field that's present in
    the emitted output

- Including links from tour-derived examples back to the relevant tour
  page feels like a win, but they need to be split over two comment
  lines or the end of the URL disappears from view. This also has the
  nice effect of pushing the URL to the second line of the editor, which
  makes the "Follow link (ctrl+click)" mouseover popup *not* get
  visually truncated by the top edge of the editor pane.

Preview-Path: /play
Signed-off-by: Jonathan Matthews <[email protected]>
Change-Id: I374ee591f767bea3a0e07f29ce7825468661f42f
Dispatch-Trailer: {"type":"trybot","CL":1188421,"patchset":3,"ref":"refs/changes/21/1188421/3","targetBranch":"master"}
cueckoo pushed a commit to cue-lang/cuelang.org that referenced this issue Mar 28, 2024
This adds a small set of representative examples to the playground,
replacing the current invalid examples.

They are placed in an indicative structure, with the "Introduction"
category being intended to hold examples for the user who landed on the
playground before reading any other part of the site, and the "Tour"
category showing a couple of CUE examples taken directly from the
on-page CUE in docs/tour/.

The Tour category isn't expanded to include all the docs examples, yet,
as both cue-lang/cue#2995 and cue-lang/cue#2900 need resolving to let us
avoid spending a *lot* of time on manual content syncing.

Formatting notes for as&when the examples are expanded, and if their
generation is automated:

- Because cue-lang/cue#722 also strikes the playground ("top-level
  comments are indented") when the playground's default of "cue eval" is
  selected, care has been taken to make sure that comments are used that
  don't trigger this bug (as it looks pretty poor for predefined
  examples to have this problem). Some relevant information:
  - only the first comment presented at the top of the "eval" output is
    affected
  - it doesn't affect comments which aren't included in the output, such
    as introductory comments which are separated by a blank line from
    the first field emitted
  - it doesn't affect fields with a struct or list value
  - it only affects single-line comments
  - it can affect a comment that's not the first line of the source, if
    it's attached to any definition of the first field that's present in
    the emitted output

- Including links from tour-derived examples back to the relevant tour
  page feels like a win, but they need to be split over two comment
  lines or the end of the URL disappears from view. This also has the
  nice effect of pushing the URL to the second line of the editor, which
  makes the "Follow link (ctrl+click)" mouseover popup *not* get
  visually truncated by the top edge of the editor pane.

For cue-lang/docs-and-content#92

Preview-Path: /play
Signed-off-by: Jonathan Matthews <[email protected]>
Change-Id: I374ee591f767bea3a0e07f29ce7825468661f42f
cueckoo pushed a commit to cue-lang/cuelang.org-trybot that referenced this issue Mar 28, 2024
This adds a small set of representative examples to the playground,
replacing the current invalid examples.

They are placed in an indicative structure, with the "Introduction"
category being intended to hold examples for the user who landed on the
playground before reading any other part of the site, and the "Tour"
category showing a couple of CUE examples taken directly from the
on-page CUE in docs/tour/.

The Tour category isn't expanded to include all the docs examples, yet,
as both cue-lang/cue#2995 and cue-lang/cue#2900 need resolving to let us
avoid spending a *lot* of time on manual content syncing.

Formatting notes for as&when the examples are expanded, and if their
generation is automated:

- Because cue-lang/cue#722 also strikes the playground ("top-level
  comments are indented") when the playground's default of "cue eval" is
  selected, care has been taken to make sure that comments are used that
  don't trigger this bug (as it looks pretty poor for predefined
  examples to have this problem). Some relevant information:
  - only the first comment presented at the top of the "eval" output is
    affected
  - it doesn't affect comments which aren't included in the output, such
    as introductory comments which are separated by a blank line from
    the first field emitted
  - it doesn't affect fields with a struct or list value
  - it only affects single-line comments
  - it can affect a comment that's not the first line of the source, if
    it's attached to any definition of the first field that's present in
    the emitted output

- Including links from tour-derived examples back to the relevant tour
  page feels like a win, but they need to be split over two comment
  lines or the end of the URL disappears from view. This also has the
  nice effect of pushing the URL to the second line of the editor, which
  makes the "Follow link (ctrl+click)" mouseover popup *not* get
  visually truncated by the top edge of the editor pane.

For cue-lang/docs-and-content#92

Preview-Path: /play
Signed-off-by: Jonathan Matthews <[email protected]>
Change-Id: I374ee591f767bea3a0e07f29ce7825468661f42f
Dispatch-Trailer: {"type":"trybot","CL":1188421,"patchset":4,"ref":"refs/changes/21/1188421/4","targetBranch":"master"}
cueckoo pushed a commit to cue-lang/cuelang.org that referenced this issue Mar 28, 2024
This adds a small set of representative examples to the playground,
replacing the current invalid examples.

They are placed in an indicative structure, with the "Introduction"
category being intended to hold examples for the user who landed on the
playground before reading any other part of the site, and the "Tour"
category showing a couple of CUE examples taken directly from the
on-page CUE in docs/tour/.

The Tour category isn't expanded to include all the docs examples, yet,
as both cue-lang/cue#2995 and cue-lang/cue#2900 need resolving to let us
avoid spending a *lot* of time on manual content syncing.

Formatting notes for as&when the examples are expanded, and if their
generation is automated:

- Because cue-lang/cue#722 also strikes the playground ("top-level
  comments are indented") when the playground's default of "cue eval" is
  selected, care has been taken to make sure that comments are used that
  don't trigger this bug (as it looks pretty poor for predefined
  examples to have this problem). Some relevant information:
  - only the first comment presented at the top of the "eval" output is
    affected
  - it doesn't affect comments which aren't included in the output, such
    as introductory comments which are separated by a blank line from
    the first field emitted
  - it doesn't affect fields with a struct or list value
  - it only affects single-line comments
  - it can affect a comment that's not the first line of the source, if
    it's attached to any definition of the first field that's present in
    the emitted output

- Including links from tour-derived examples back to the relevant tour
  page feels like a win, but they need to be split over two comment
  lines or the end of the URL disappears from view. This also has the
  nice effect of pushing the URL to the second line of the editor, which
  makes the "Follow link (ctrl+click)" mouseover popup *not* get
  visually truncated by the top edge of the editor pane.

For cue-lang/docs-and-content#92

Preview-Path: /play
Signed-off-by: Jonathan Matthews <[email protected]>
Change-Id: I374ee591f767bea3a0e07f29ce7825468661f42f
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cuelang.org/+/1188421
Reviewed-by: Paul Jolly <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
@jpluscplusm jpluscplusm changed the title cuelang.org: make examples' files available in a repo cuelang.org: preprocessor: make examples' files available in a repo Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

2 participants