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

Docs: Updated Custom Filters #395

Merged
merged 2 commits into from
Sep 16, 2021

Conversation

markmandel
Copy link
Contributor

Updates the custom filter documentation to the latest API changes.

This also includes using mdbook's include preprocessor to inject the example code into the documentation.

Note: Because of the use of include preprocessor I had to remove the Markdown lists, as they wouldn't format correctly
(See: rust-lang/mdBook#1564).

Closes #373

Updates the custom filter documentation to the latest API changes.

This also includes using mdbook's `include` preprocessor to inject the
example code into the documentation.

Note: Because of the use of `include` preprocessor I had to remove the
Markdown lists, as they wouldn't format correctly
(See: rust-lang/mdBook#1564).

Closes googleforgames#373
@@ -3,27 +3,27 @@
Quilkin provides an extensible implementation of [Filters] that allows us to plug in custom implementations to fit our needs.
This document provides an overview of the API and how we can go about writing our own [Filters].

#### API Components
## API Components
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just noting: Since I had to remove the lists, I moved the headers to be in level order. PTAL, let me know what you think.

```rust,no_run,noplayground
struct Greet;

impl Filter for Greet {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't include this, so just copied it inline. In theory it could go out of date, but I couldn't think of a better way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should no longer apply, as now it matches how it was before.

@markmandel
Copy link
Contributor Author

Looks like I broke a stack of the docs tests. I'll swing back to this tomorrow and see if I can fix them / if they should be ignored.

@quilkin-bot
Copy link
Collaborator

Build Failed 😭

Build Id: 004feda8-538d-4908-bac5-ba04e2f4f23f

Status: FAILURE

To get permission to view the Cloud Build view, join the quilkin-discuss Google Group.

Comment on lines 105 to 106
> As a convention we implement a `pub factory() -> DynFilterFactory` function, to
> make the next integration step easier.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is correct? the factory() function or constructor wouldn't be visible at all from user code and what's passed into quilkin is the DynFilterFactory so it doesn't matter how the object is generated?

Suggested change
> As a convention we implement a `pub factory() -> DynFilterFactory` function, to
> make the next integration step easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just so I'm clear, are you saying the description isn't correct?

If I look at all our Filter implementations, they all have a pub factory() -> DynFilterFactory - so I thought it would be good to call out that we conventionally do that, and why.

You are 100% correct that the end use could create a constructor any way, but I thought it would be good to show our usual convention. Maybe the description should be:

As a convention we generally implement a pub factory() -> DynFilterFactory function as a constructor, but a Factory
can be constructed as you see fit.

To explain that while you may see this common pattern, it's more by convention, rather than technical limitation. WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, the incorrect part was mostly the 'to make the next integration step easier' bit since the function itself didn't matter.

I think in this case the fact that the quilkin codebase used a function called factory vs anything else doesn't matter at all so it can add confusion to call it out in the first place (as a user I'd find myself reading into what that means and quickly realise it doesn't matter which is wasted time), the user would declare and call the function within their own crate so the function can be called anything or they could construct the factory by some other means (I don't see it as a convention here since both crates don't need to worry about it in the first place).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's fair. Sounds good, I'll remove the comment 👍🏻

Worst case, if people start asking, we can add it back in 😄

@iffyio iffyio mentioned this pull request Sep 14, 2021
@markmandel
Copy link
Contributor Author

Updated, so now it should pass -- basically put the include sections back the way they were before, and updated the include sections so that they have a // src/main.rs (or similar) comment like they did previously.

Also updated the initial examples include to use use quilkin::filters::prelude::*; - since that is also what we're generally using now as well.

@markmandel markmandel force-pushed the docs/example-filter-update branch from 599f221 to 4a0c8a4 Compare September 14, 2021 22:06
@quilkin-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: 30356946-5915-4913-8bcc-8c8b45b8869b

To build this version:

git fetch git@github.com:googleforgames/quilkin.git pull/395/head:pr_395 && git checkout pr_395
cargo build

@quilkin-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: 6261f220-b1b4-443f-8e29-bdcba19d3897

To build this version:

git fetch git@github.com:googleforgames/quilkin.git pull/395/head:pr_395 && git checkout pr_395
cargo build

Review Updates.
@markmandel markmandel force-pushed the docs/example-filter-update branch from 4a0c8a4 to 059c66b Compare September 15, 2021 18:14
@quilkin-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: 43e02ee7-7ae8-448d-b4f5-a7f1f97dfd4f

To build this version:

git fetch git@github.com:googleforgames/quilkin.git pull/395/head:pr_395 && git checkout pr_395
cargo build

@markmandel markmandel added this to the 0.2.0 milestone Sep 16, 2021
@markmandel markmandel merged commit e2039c3 into googleforgames:main Sep 16, 2021
@markmandel markmandel deleted the docs/example-filter-update branch September 16, 2021 00:04
@markmandel markmandel added kind/cleanup Refactoring code, fixing up documentation, etc kind/documentation Improvements or additions to documentation labels Sep 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes kind/cleanup Refactoring code, fixing up documentation, etc kind/documentation Improvements or additions to documentation size/l
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Review Docs: Writing Custom Filters for API changes
3 participants