-
Notifications
You must be signed in to change notification settings - Fork 159
Custom analysis for packages which are tools #3657
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
Comments
I think Maybe we should do a top-level analysis of the readme, and if the section has a recognized title (e.g. installing, setup, usage, example use) then we can use that and do not require the separate file? |
Hey, I would like to work on this. Could you point me in a direction from where I could get started? |
@ramyak-mehra: we are using package:markdown to parse the |
@isoos So far I have come up with something like this (not refined) List<String> _recognizedTitles = ['installing', 'setup', 'usage', 'example'];
var document = Document();
var markdown = '';
var lines = markdown.replaceAll('\r\n', '\n').split('\n');
var htmlLines = HtmlRenderer().render(document.parseLines(lines)).split('\n');
_extract(htmlLines);
bool _extract(List<String> htmlLines) {
htmlLines.forEach((element) {
if (_checkIfTitle(element)) {
return true;
}
});
return false;
}
bool _checkIfTitle(String content) {
_recognizedTitles.forEach((element) {
if (content.contains(element)) {
return true;
}
});
return false;
} We can use this here |
@ramyak-mehra: Code like this may be good for a large number of text content, but in general we try to recognise the structure from the parsed syntax tree. One example of such processing is the current changelog updater code: We would like to see a generic processing similar to that, which would extract the hierarchical structure of the markdown (in typed classes), and then decide the content extraction based on that structure. |
@isoos If I am understanding it correctly we should have some kind of iterable or list in the hierarchical order of the markdown which has elements in typed classes such as different classes for heading, paragraph, etc and from that, we can make the decision? |
@ramyak-mehra: I'm thinking more in a tree, like: class Section {
final int level;
final markdown.Node titleNode;
final List<markdown.Node> contentNodes;
List<Section> children;
} Maybe further methods to extract the text content of |
@isoos I was doing something like this github gist . Probably not the best approach and I found this node visitor |
@ramyak-mehra: as a quick look, I think this code is very early stage, and possible won't handle use case like this:
Which should result in the structure of:
As you can see, the |
It was just a starting point for me to move forward. I have one doubt for h1 section of multiple h2s are children or h2 , h3 ,h4 ... h6 are children |
It will be hard to detect this reliably automatically. We probably want people to declare this in the pubspec somehow. Maybe something like
If we know a package is a "dev" tool, the install-page could suggest installing as a dev-dependency if it is a "global" we can show how to global-install it. To aid discovery we could do a publish validation (or pana scoring), that suggests declaring these if your Can a package be both a library and a tool ? Probably. |
Some of our analysis guidelines make no sense for packages which are tools (e.g. stagehand), for example here's an issue with a tool loosing points over not having an example file: dart-archive/stagehand#638 (comment)
The text was updated successfully, but these errors were encountered: