-
Notifications
You must be signed in to change notification settings - Fork 36
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
Split parser functionality into its own package? #75
Comments
Maybe reach out to the phpdocumentor devs to have a repo in their org ? I am not sure what is the end goal and if this is the right project for the task. As here it is mostly parse and display stuff Let me know more |
The code I'm using is specifically in this package right now - I'm proposing it gets separated out into a separate package, whether that ends up being in a different GitHub organisation or not isn't really for me to decide or negotiate.
My tool is using code that's currently in doctum for getting full class hierarchy API surface data across two different versions, which will then be compared in a separate step. Basically, doctum has two steps:
My tool will work similarly:
Expand to see the code I'm playing with#!/usr/bin/env php
<?php
use Doctum\Parser\ClassVisitor;
use Doctum\Parser\CodeParser;
use Doctum\Parser\DocBlockParser;
use Doctum\Parser\Filter\DefaultFilter;
use Doctum\Parser\NodeVisitor;
use Doctum\Parser\Parser;
use Doctum\Parser\ParserContext;
use Doctum\Parser\ProjectTraverser;
use Doctum\Project;
use Doctum\Store\JsonStore;
use Gsartorelli\DoctumPlayground\RecipeFinder;
use Gsartorelli\DoctumPlayground\RecipeVersionCollection;
use PhpParser\NodeTraverser;
use PhpParser\NodeVisitor\NameResolver;
use PhpParser\ParserFactory;
use PhpParser\PrettyPrinter\Standard as PrettyPrinter;
require_once __DIR__ . '/vendor/autoload.php';
$collection = new RecipeVersionCollection();
$store = new JsonStore();
$project = new Project(
$store,
$collection,
[
'build_dir' => '/home/gsartorelli/dump/temp/doctum-dump/%version%/',
'cache_dir' => '/home/gsartorelli/dump/temp/doctum-cache/%version%/',
'include_parent_data' => true,
]
);
$iterator = new RecipeFinder($collection);
$iterator
->files()
->name('*.php')
->exclude('thirdparty')
->exclude('examples')
->exclude('tests');
$parserContext = new ParserContext(new DefaultFilter(), new DocBlockParser(), new PrettyPrinter());
$traverser = new NodeTraverser();
$traverser->addVisitor(new NameResolver());
$traverser->addVisitor(new NodeVisitor($parserContext));
$codeParser = new CodeParser($parserContext, (new ParserFactory())->create(ParserFactory::PREFER_PHP7), $traverser); // @TODO use PHP version detection per recipe version
$visitors = [
new ClassVisitor\InheritdocClassVisitor(),
new ClassVisitor\MethodClassVisitor(),
new ClassVisitor\PropertyClassVisitor($parserContext),
];
$projectTraverser = new ProjectTraverser($visitors);
$parser = new Parser($iterator, $store, $codeParser, $projectTraverser);
$project->setParser($parser);
$project->parse(); // @todo can use callback to output current step
// @TODO comparison step now we've parsed all relevant versions of all relevant packages |
I'm writing a tool that helps me find all of the API breaking changes between two versions of a large, multi-repo project, and I've found that a lot of the parser tools this repository has (e.g. referencing a "project" at the top level, from which I can find reflection about various items) is immensely helpful.
I was wondering if you'd consider splitting the parser functionality out as its own package, which would then be a dependency of doctum?
The text was updated successfully, but these errors were encountered: