Skip to content

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

Merged
merged 2 commits into from
Dec 2, 2016
Merged

Conversation

dbu
Copy link
Contributor

@dbu dbu commented Oct 18, 2016

fix #141

@@ -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:
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 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:
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 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::
Copy link
Member

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).

Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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.

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 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?

Copy link
Member

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.

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 adjusted some of the naming. in many places, we do explicitly mean a message factory and not any http factory.

@dbu dbu force-pushed the factories-doc-improvements branch from 3d10ef3 to 600f259 Compare October 18, 2016 08:36
$apiClient = new ApiClient(
new DiactorosMessageFactory(),
new DiactorosStreamFactory(),
new DiactorosUriFactory()
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

Copy link
Member

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::
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

If you **only** ...

Copy link
Contributor Author

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?

@dbu dbu force-pushed the factories-doc-improvements branch from 600f259 to afdb9f3 Compare October 20, 2016 06:48
@dbu dbu force-pushed the factories-doc-improvements branch from afdb9f3 to c6e5e49 Compare October 25, 2016 14:53
.. 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
Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Member

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.

@dbu
Copy link
Contributor Author

dbu commented Nov 4, 2016

i updated this. any more feedback? anybody got an idea on the "vice versa" the spellcheck does not like?

Copy link
Member

@Nyholm Nyholm left a 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.

@dbu dbu force-pushed the factories-doc-improvements branch from c6e5e49 to 7e49895 Compare November 18, 2016 12:28
@dbu
Copy link
Contributor Author

dbu commented Nov 18, 2016

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
Copy link
Member

@xabbuh xabbuh Nov 25, 2016

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"?

@dbu dbu force-pushed the factories-doc-improvements branch from 7e49895 to 3eca342 Compare November 30, 2016 13:58
@dbu
Copy link
Contributor Author

dbu commented Nov 30, 2016

fixed double whitespace. ok like this, or any other change swe need?

@sagikazarmark sagikazarmark merged commit 0f2b962 into master Dec 2, 2016
@sagikazarmark sagikazarmark deleted the factories-doc-improvements branch December 2, 2016 11:29
@sagikazarmark
Copy link
Member

Huh @dbu, you've got some nerves for doing the ugliest job dev can do: docs. 😝

@dbu
Copy link
Contributor Author

dbu commented Dec 2, 2016

i find it something extermly important :-) and sometimes i even enjoy doing it

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.

title of doc section on factories
5 participants