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

chore(external docs): render array of object type in component docs #22138

Merged

Conversation

titaneric
Copy link
Contributor

@titaneric titaneric commented Jan 7, 2025

Summary

Try to resolve #22136.

log_to_metric transforms

image

static metric

image

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

How did you test this PR?

make quick-build
make serve

Navigate to log to metric transforms and static metric

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the "no-changelog" label to this PR.

Checklist

  • Please read our Vector contributor resources.
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run dd-rust-license-tool write to regenerate the license inventory and commit the changes (if any). More details here.

References

Close #22136

@titaneric
Copy link
Contributor Author

I have to admit that I am neither a frontend engineer nor a UI expert, but I have added some margin same as array's example, and I need some time to compare the implementation between mine and data model rendering.

@pront
Copy link
Member

pront commented Jan 7, 2025

I have to admit that I am neither a frontend engineer nor a UI expert, but I have added some margin same as array's example, and I need some time to compare the implementation between mine and data model rendering.

I appreciate your efforts on this. I am also not an expert with frontend stuff. If it helps, this is how I test Vector website locally:

cd /path/to/vector/root
# make generate-component-docs # needed only if you modify configurable components in Rust
cd website
make run-production-site-locally

Need to install Hugo e.g. brew install hugo for the above to work.

@titaneric
Copy link
Contributor Author

Added some margin on top of config object
image

Decrease the margin on top of array example and make it consistent to padding of outer container.
image

image

Now the doc looks right enough, but I am welcome to here more suggestions.

@titaneric titaneric marked this pull request as ready for review January 8, 2025 03:41
@titaneric titaneric requested review from a team as code owners January 8, 2025 03:41
@pront
Copy link
Member

pront commented Jan 8, 2025

Thank you this is a great improvement.

I noticed in one of your screenshots this grey bubble:
image. I wonder if that is also a rendering bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Node that Line 119 (rendering config object) has the similar margin.

@titaneric
Copy link
Contributor Author

Let me take a look at the grey bubble

@titaneric
Copy link
Contributor Author

titaneric commented Jan 8, 2025

It takes charge to render the v.syntax such as template, regex, string and so on. But there is no syntax defined in metric field in log_to_metric transforms, so it just render an empty bubble here. Perhaps we could conditionally render the gray bubble when there is syntax field defined?

@titaneric
Copy link
Contributor Author

titaneric commented Jan 8, 2025

A more serious issue encountered. I want to add syntax field to preview the rendering result:

	metrics: {
		description: "A list of metrics to generate."
		required:    true
		type: array: items: type: object {
			examples: [
				{
					field: "value_transform_total"
					counter: {
						value: 10.0
					}
					kind: "incremental"
					name: "test.transform.counter"
					tags: {
						env:  "test_env"
						host: "localhost"
					}
				},
			]
			syntax: "template"

but I have the following error:

components.transforms.log_to_metric.configuration.metrics.type.array.items.type.object.syntax: field not allowed

It seems that it does not fit the current schema? Perhaps deleting the gray bubble is another solution.


Updated:

Okay, now I fully understand how the schema in cue works in vector, there is no syntax field defined in TypeArray, so it breaks the syntax when I want to add syntax field in metric type.

Copy link
Member

@pront pront left a comment

Choose a reason for hiding this comment

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

LGTM

How does this look to you? cc @jszwedko

Copy link
Member

@jszwedko jszwedko left a comment

Choose a reason for hiding this comment

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

Nice work on this @titaneric . This issue has been a pet peeve for me for a long while but I was never able to muster the energy to dig into it. The rendering looks good to me. I would like to see if we could drop that extra grey syntax oval if possible.

@titaneric titaneric changed the title chore(docs): render array of object type in component docs chore(external docs): render array of object type in component docs Jan 9, 2025
@titaneric
Copy link
Contributor Author

Thank you, I think if syntax is not necessary for the array type and we could simply delete it since it's not defined in the array's schema.

@pront
Copy link
Member

pront commented Jan 9, 2025

Thank you, I think if syntax is not necessary for the array type and we could simply delete it since it's not defined in the array's schema.

As you pointed it out, syntax isn't defined there. If you have a few minutes you could just define it (like so) and see how it renders, if the result is not good, let's just delete it 👍

@titaneric
Copy link
Contributor Author

I have deleted it! Hope that the preview website could be successfully deployed.

@pront
Copy link
Member

pront commented Jan 9, 2025

Great improvement:
image

Tangential: Hmm the website wasn't generated even the though there's website in the branch name. Maybe it doesn't work on fork brances. cc @devindford

@pront pront added the no-changelog Changes in this PR do not need user-facing explanations in the release changelog label Jan 9, 2025
@jszwedko
Copy link
Member

jszwedko commented Jan 9, 2025

Awesome, thanks for this fix @titaneric !

@pront pront enabled auto-merge January 9, 2025 15:36
@pront pront added this pull request to the merge queue Jan 9, 2025
Copy link
Member

@jszwedko jszwedko left a comment

Choose a reason for hiding this comment

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

Actually, I'm sorry, I think this isn't quite right. This removes the syntax for arrays of elements that do have syntax.

For example, group_by for reduce:

Before this change:

Screenshot 2025-01-09 at 7 37 08 AM

After this change:

Screenshot 2025-01-09 at 7 37 03 AM

Notice literal is removed.

@pront pront removed this pull request from the merge queue due to a manual request Jan 9, 2025
@titaneric
Copy link
Contributor Author

Thank you for pointing out this one. I am wondering why array type could have syntax field. Let me dig into it.

@titaneric
Copy link
Contributor Author

Ok, I find there is a syntax filed defined in string, and it would render the syntax on the page since the group_by is the array of string. Let me fix it.

@titaneric
Copy link
Contributor Author

titaneric commented Jan 9, 2025

I conditionally render the page if the $v.syntax is defined.

reduce page:
image

log_to_metric page:
image

@titaneric titaneric requested a review from a team as a code owner January 9, 2025 15:58
@github-actions github-actions bot added domain: sources Anything related to the Vector's sources domain: transforms Anything related to Vector's transform components domain: sinks Anything related to the Vector's sinks domain: releasing Anything related to releasing Vector domain: external docs Anything related to Vector's external, public documentation domain: vdev Anything related to the vdev tooling labels Jan 9, 2025
@titaneric titaneric force-pushed the website/render-array-object-docs branch from 303b12c to ff6f9c8 Compare January 9, 2025 16:01
@github-actions github-actions bot removed domain: sources Anything related to the Vector's sources domain: transforms Anything related to Vector's transform components domain: sinks Anything related to the Vector's sinks domain: releasing Anything related to releasing Vector domain: external docs Anything related to Vector's external, public documentation domain: vdev Anything related to the vdev tooling labels Jan 9, 2025
@titaneric titaneric requested a review from jszwedko January 9, 2025 16:02
Copy link
Member

@jszwedko jszwedko left a comment

Choose a reason for hiding this comment

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

Awesome, thanks @titaneric ! This looks good to me now (both the reduce and log_to_metric transform pages).

@jszwedko jszwedko enabled auto-merge January 9, 2025 18:03
@jszwedko jszwedko added this pull request to the merge queue Jan 9, 2025
Merged via the queue into vectordotdev:master with commit 99af5be Jan 9, 2025
55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Changes in this PR do not need user-facing explanations in the release changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vector's doc doesn't properly render array type in component page
4 participants