mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-11-25 10:10:32 -06:00
stub in docs services
This commit is contained in:
parent
b1822a3548
commit
d53f62de74
@ -0,0 +1,35 @@
|
||||
package io.nosqlbench.engine.docs;
|
||||
|
||||
import io.nosqlbench.docsys.api.Docs;
|
||||
import io.nosqlbench.docsys.api.DocsBinder;
|
||||
import io.nosqlbench.nb.api.annotations.Service;
|
||||
import io.nosqlbench.nb.api.content.Content;
|
||||
import io.nosqlbench.nb.api.content.NBIO;
|
||||
import io.nosqlbench.nb.api.content.NBIOWalker;
|
||||
import io.nosqlbench.nb.api.content.PathContent;
|
||||
import io.nosqlbench.nb.api.markdown.providers.MarkdownProvider;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service(MarkdownProvider.class)
|
||||
public class NosqlBenchMarkdownSource implements MarkdownProvider {
|
||||
|
||||
@Override
|
||||
public List<Content<?>> getMarkdownInfo() {
|
||||
Path docspath = NBIO.local().name("docs-for-eb")
|
||||
.one().asPath();
|
||||
NBIOWalker.CollectVisitor capture = new NBIOWalker.CollectVisitor(true, false);
|
||||
NBIOWalker.RegexFilter filter = new NBIOWalker.RegexFilter("\\.md",true);
|
||||
NBIOWalker.walkFullPath(docspath,capture,filter);
|
||||
|
||||
List<Content<?>> content = new ArrayList<>();
|
||||
for (Path path : capture.get()) {
|
||||
content.add(new PathContent(path));
|
||||
}
|
||||
return content;
|
||||
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package io.nosqlbench.nb.api.markdown.descriptor;
|
||||
package io.nosqlbench.nb.api.markdown.aggregator;
|
||||
|
||||
/**
|
||||
* DocScope determines which display mode a topic is meant to be displayed in.
|
@ -1,4 +1,4 @@
|
||||
package io.nosqlbench.nb.api.markdown.descriptor;
|
||||
package io.nosqlbench.nb.api.markdown.aggregator;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
@ -0,0 +1,56 @@
|
||||
package io.nosqlbench.nb.api.markdown.aggregator;
|
||||
|
||||
import com.vladsch.flexmark.ext.yaml.front.matter.AbstractYamlFrontMatterVisitor;
|
||||
import com.vladsch.flexmark.ext.yaml.front.matter.YamlFrontMatterExtension;
|
||||
import com.vladsch.flexmark.html2md.converter.FlexmarkHtmlConverter;
|
||||
import com.vladsch.flexmark.parser.Parser;
|
||||
import com.vladsch.flexmark.util.ast.Document;
|
||||
import io.nosqlbench.nb.api.content.Content;
|
||||
import io.nosqlbench.nb.api.markdown.FlexParser;
|
||||
import io.nosqlbench.nb.api.markdown.providers.MarkdownProviders;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MarkdownDocs {
|
||||
|
||||
private static FlexmarkHtmlConverter converter = FlexmarkHtmlConverter.builder()
|
||||
.extensions(List.of(YamlFrontMatterExtension.create()))
|
||||
.build();
|
||||
|
||||
public static MarkdownInfo find(DocScope... scopes) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<MarkdownInfo> find(String name, DocScope... scopes) {
|
||||
List<MarkdownInfo> aggregated = new ArrayList<>();
|
||||
|
||||
List<Content<?>> markdownContent = MarkdownProviders.getAllMarkdown();
|
||||
MarkdownInfo info = new MutableMarkdownInfo();
|
||||
|
||||
// Find all topics and aggregators
|
||||
List<String> aggregators = new ArrayList<>();
|
||||
List<String> topics = new ArrayList<>();
|
||||
|
||||
for (Content<?> content : markdownContent) {
|
||||
String markdown = content.asString();
|
||||
String convert = converter.convert(markdown);
|
||||
|
||||
AbstractYamlFrontMatterVisitor v = new AbstractYamlFrontMatterVisitor();
|
||||
Document parsed = FlexParser.parser.parse(markdown);
|
||||
|
||||
v.visit(parsed);
|
||||
Map<String, List<String>> data = v.getData();
|
||||
System.out.print("frontmatter for " + content.asPath());
|
||||
for (Map.Entry<String, List<String>> e : data.entrySet()) {
|
||||
System.out.println("k : " + e.getKey());
|
||||
System.out.println(" v:" + String.join(",",e.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
return aggregated;
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
package io.nosqlbench.nb.api.markdown.descriptor;
|
||||
package io.nosqlbench.nb.api.markdown.aggregator;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public interface MarkdownInfo {
|
||||
Path getPath();
|
||||
CharSequence getBody();
|
||||
String getBody();
|
||||
FrontMatter getFrontmatter();
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package io.nosqlbench.nb.api.markdown.aggregator;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class MutableMarkdownInfo implements MarkdownInfo {
|
||||
@Override
|
||||
public Path getPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBody() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FrontMatter getFrontmatter() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package io.nosqlbench.nb.api.markdown.finder;
|
||||
|
||||
import io.nosqlbench.nb.api.markdown.descriptor.DocScope;
|
||||
import io.nosqlbench.nb.api.markdown.descriptor.MarkdownInfo;
|
||||
|
||||
public class MarkdownLoader {
|
||||
public static MarkdownInfo find(DocScope... scopes) {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Because documentation is meant to be provide across all modules
|
||||
* to both developers and users, the markdown support for NoSQLBench
|
||||
* is considered a core API.
|
||||
*/
|
||||
package io.nosqlbench.nb.api.markdown;
|
@ -1,4 +1,6 @@
|
||||
package io.nosqlbench.nb.api.markdown.descriptor;
|
||||
package io.nosqlbench.nb.api.markdown.providers;
|
||||
|
||||
import io.nosqlbench.nb.api.content.Content;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -6,5 +8,5 @@ import java.util.List;
|
||||
* A MarkdownProvider simply provides all the markdown content it is aware of.
|
||||
*/
|
||||
public interface MarkdownProvider {
|
||||
List<MarkdownInfo> getMarkdownInfo();
|
||||
List<Content<?>> getMarkdownInfo();
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package io.nosqlbench.nb.api.markdown.providers;
|
||||
|
||||
import io.nosqlbench.nb.api.content.Content;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* The internal
|
||||
*/
|
||||
public class MarkdownProviders {
|
||||
|
||||
public static List<Content<?>> getAllMarkdown() {
|
||||
ServiceLoader<MarkdownProvider> loader = ServiceLoader.load(MarkdownProvider.class);
|
||||
List<Content<?>> names = new ArrayList<>();
|
||||
loader.iterator().forEachRemaining(d -> names.addAll(d.getMarkdownInfo()));
|
||||
return names;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user