-
Notifications
You must be signed in to change notification settings - Fork 56
improve factories documentation #161
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
Conversation
@@ -13,6 +13,3 @@ This package contains various PSR-7 tools which might be useful in an HTTP workf | |||
* Message decorators | |||
* Message factory implementations for Guzzle PSR-7, Diactoros and Slim Framework. | |||
* Cookie implementation | |||
|
|||
.. _message-factory: |
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.
i am surprised sphinx did not complain about the duplicated reference target. it makes no sense to have this here, its in message-factory.rst
@@ -1,57 +1,124 @@ | |||
.. _message-factory: |
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.
this file is still named message-factory.rst, which shows in the url. but i think as the package is called message-factory as well, its ok to keep that name.
new DiactorosUriFactory() | ||
); | ||
|
||
You could also use :doc:`/discovery` to automatically find an available factory:: |
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.
This part probably recommends against how we usually use discovery (inside the client with optional arguments).
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.
Yes, I think we should update this to use optional arguments.
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.
indeed. will change this example
|
||
Message Factory | ||
=============== | ||
HTTP Factories |
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.
Although I agree that they are not really Message Factories in most places we refer to them as message factories. The file name also says message-factory, so this could be a little bit confusing.
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.
that was the initial question in #141. i find "Message Factory" wrong here. what should we call it? "Message Factories" is wrong, uri and stream are not messages. other ideas? or should i hunt through the doc and change "message factory" to "http factory" where i find that?
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.
should i hunt through the doc and change "message factory" to "http factory" where i find that?
I am all for consistency.
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.
i adjusted some of the naming. in many places, we do explicitly mean a message factory and not any http factory.
3d10ef3
to
600f259
Compare
$apiClient = new ApiClient( | ||
new DiactorosMessageFactory(), | ||
new DiactorosStreamFactory(), | ||
new DiactorosUriFactory() |
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.
You would rarely use the URI Factory since it is required by the message factory.
I suggest removing it.
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.
hm. i want to show how to create all 3 factories in the example. and i guess there are use cases where you e.g. accept a url string and create the uri from it in your api client to do some uri manipulations before creating the request.
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.
are you ok if we leave this as is?
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.
I am fine with that
new DiactorosUriFactory() | ||
); | ||
|
||
You could also use :doc:`/discovery` to automatically find an available factory:: |
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.
Yes, I think we should update this to use optional arguments.
|
||
.. hint:: | ||
|
||
If you only create requests, use ``RequestFactory`` in the type hint, rather |
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.
If you **only** ...
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.
did not follow your suggestion, but tried to formulate this more explicit. better?
600f259
to
afdb9f3
Compare
afdb9f3
to
c6e5e49
Compare
.. hint:: | ||
|
||
If you create requests only and no responses, use ``RequestFactory`` in the | ||
type hint, instead of the ``MessageFactory``. And vice versa if you create |
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.
spelling does not like this. is this proper english or not?
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.
Actually it's latin, but should be ok. Just add it to the spellcheck list.
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.
Already see this in english, you can also use "And conversely" if you want, but i think "vice versa" is better.
i updated this. any more feedback? anybody got an idea on the "vice versa" the spellcheck does not like? |
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.
Sorry for being slow reviewing this.
c6e5e49
to
7e49895
Compare
added versa to the spell word list, as it seems to be correct to use this in english. @sagikazarmark are you ok with this now, anything else i should add? |
The factories abstract away from this. | ||
While it should be possible to use every PSR-7 aware HTTP client with any | ||
request, URI and stream implementation, instantiating objects explicitly would | ||
still tie the code to a specific implementation. If each reusable library is |
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.
A bit nitpicking: Two spaces between "still" and "tie"?
7e49895
to
3eca342
Compare
fixed double whitespace. ok like this, or any other change swe need? |
Huh @dbu, you've got some nerves for doing the ugliest job dev can do: docs. 😝 |
i find it something extermly important :-) and sometimes i even enjoy doing it |
fix #141