Skip to content

Created a doc builder, doc config and doc result classes #71

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 6 commits into from
Mar 17, 2021

Conversation

javiereguiluz
Copy link
Collaborator

This parser was originally created with this target -> "integrating it in symofny.com should require the absolute minimum number of changes". That's where the PHAR and command made a lot of sense.

However, circumstances have changed completely. Now the target is "to create the best possible PHP-based RST parser and doc builder". That means less maintenance, less things to set up, less concepts to learn etc. That's why I created this PR.

The idea is that parsing RST contents would mean to run composer require <this-package> and then do this in your own code:

$buildResult = $docBuilder->build($buildConfig);

Comments:

  • The BuildResult class is a very simple value object to abstract all the build error messages.
  • The DocBuilder is completely new ... but it's based on the command previously used to build docs.
  • BuildConfig is a rename + simplification of the previous BuildContext. I think the new name is more precise, because this object mostly/only stores config values and no state/context.
  • I also added some new options to BuildConfig which we need in CopyImagesListener.

I know this looks like a lot of changes ... but I consider it just a simplification of the current code. I thank you all for the previous work which provided a solid foundation.

Lastly, I've been using this for weeks to build bundles docs in symfony.com with success, so I consider this tested enough 🤞

@javiereguiluz
Copy link
Collaborator Author

If possible, let's merge this soon and tag a new version because we want to start using this in symfony.com. Thanks!

@nikophil
Copy link
Collaborator

because the new DocsBuilder will be at the center of the lib, shouldn't we provide some unit/functional tests for it?

maybe before we merge @weaverryan could you review this, please?

Copy link
Contributor

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

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

I love the simplification! I left a few comments... that we can deal with later.

@@ -17,23 +17,12 @@
class Application
{
private $application;
private $buildContext;
private $buildConfig;

public function __construct(string $symfonyVersion)
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need this argument anymore, right? Or if we do, we should pass it directly into BuildConfig to set its version (which currently has a hardcoded default of 4.4)?

use SymfonyDocsBuilder\Generator\HtmlForPdfGenerator;
use SymfonyDocsBuilder\Generator\JsonGenerator;

final class DocBuilder
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless I'm missing something, this class isn't used anywhere IN the bundle. It's just a public class that can be consumed by any project. If we DO decide to keep the BuildDocsCommand, I guess that command should also (in the future) use this class.

Copy link
Contributor

Choose a reason for hiding this comment

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

As far as tests go, if this is the central mechanism to build the docs, then this could/should be used in the IntegrationTest :)

@weaverryan weaverryan merged commit b945a54 into symfony-tools:master Mar 17, 2021
@javiereguiluz javiereguiluz deleted the builder branch March 17, 2021 13:42
@javiereguiluz
Copy link
Collaborator Author

Thanks for the review and the quick merge!

@nikophil you are right that we should test more ... but given that we are the only users of this project, I think it's reasonable to be agile/fast now (while we're integrating this in symfony.com) and then make things more robust when this integration is finished. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants