move some doc apis to core API layer

This commit is contained in:
Jonathan Shook
2022-01-10 22:24:33 -06:00
parent 6e1790057d
commit c27630e5a6
16 changed files with 22 additions and 15 deletions

View File

@@ -1,7 +1,7 @@
package io.nosqlbench.docsys;
import io.nosqlbench.docsys.api.Docs;
import io.nosqlbench.docsys.api.DocsBinder;
import io.nosqlbench.docapi.Docs;
import io.nosqlbench.docapi.DocsBinder;
import io.nosqlbench.docsys.api.DocsysStaticManifest;
//@Service(DocsysStaticManifest.class)

View File

@@ -1,79 +0,0 @@
package io.nosqlbench.docsys.api;
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* DocsInfo is a manifest view of a set of namespaces and included
* paths. The namespaces act as content slots to allow content to be
* managed by different layers of artifacts. For example, a downstream
* artifact can replace a context by replacing the same-named namespace.
*
* <pre>{@code
* docsinfo = {
* 'namespaces': [
* {
* 'namespace': 'example-namespace-1',
* 'paths': ['path1','path2']
* },
* {
* 'namespace': 'example-namespace-2',
* 'paths': ['path-foo','other-path']
* }
* ]
* }
* }</pre>
*
* Internally, The namespace entries are represented by {@link DocsNameSpace} types.
*/
public interface DocsBinder extends Iterable<DocsNameSpace> {
/**
* The result of merging two DocsInfo elements together
* is a combined DocsInfo element with all unique namespaces
* occurring exactly once, and with the other namespace overwriting
* same-named namespaces in the original element.
*
* @param other The DocsInfo containing namespaces to overlay into this DocsInfo
* @return
*/
DocsBinder merge(DocsBinder other);
/**
* The result of merging a DocPathInfo entry into a DocsInfo element
* is the combined DocsInfo element with the added entry overwriting
* any namespace of the same name.
*
* @param other The namespace entry to overlay into this DocsInfo
* @return
*/
DocsBinder merge(DocsNameSpace other);
/**
* The result of removing a set of namespaces from a DocsInfo element
* is a new DocsInfo element containing only the namespaces which were
* removed. The original DocsInfo element is modified statefully in this
* case. It is not an error to remove namespaces which are not present
* in the original DocsInfo. If this condition is important, check for it
* manually.
*
* @param namespaces The names of the namespaces to remove, should they
* be present.
* @return A new DocsInfo object representing what was actually removed.
*/
DocsBinder remove(Set<String> namespaces);
/**
* @return All paths in all namespaces are returned, in no guaranteed order.
*/
List<Path> getPaths();
/**
* @return A map of all namespaces to each set of provided paths is returned.
*/
Map<String, Set<Path>> getPathMap();
List<DocsNameSpace> getNamespaces();
}

View File

@@ -1,39 +0,0 @@
package io.nosqlbench.docsys.api;
import java.nio.file.Path;
import java.util.List;
/**
* Doc Path Info represents a readable Path which is part of a well-known
* namespace.
*
* <pre>{@code
* docpathinfo = {
* 'namespace': 'example-namespace',
* 'paths': ['path1', 'path2']
* }
*
* }</pre>
*
* When callers are using doc paths from this interface, it is an error for
* there to be multiple instance of a doc path of the same name in the same
* namespace. As long as the root path of a doc tree is unique within the
* given namespaces, they may be merged. This is to allow multiple contributors
* of detailed docs to a single known namespace.
*
*/
public interface DocsNameSpace extends Iterable<Path> {
/**
* A simple name which can be used to nest the enclosed path within a larger
* namespace. Users of this interface should never host content from the path
* at a root level separate from the namespace.
*
* @return A canonical namespace identifier
*/
String getName();
List<Path> getPaths();
boolean isEnabledByDefault();
}

View File

@@ -1,68 +0,0 @@
package io.nosqlbench.docsys.api;
import java.nio.file.Path;
import java.util.*;
public class DocsNameSpaceImpl implements DocsNameSpace {
private final Set<Path> paths = new HashSet<>();
private String namespace;
private boolean enabledByDefault = false;
public DocsNameSpaceImpl() {}
public static DocsNameSpaceImpl of(String descriptiveName, Path path) {
return new DocsNameSpaceImpl().setNameSpace(descriptiveName).addPath(path);
}
private DocsNameSpaceImpl setNameSpace(String namespace) {
this.namespace = namespace;
return this;
}
public DocsNameSpaceImpl(String name) {
this.namespace = name;
}
public String getName() {
return namespace;
}
@Override
public List<Path> getPaths() {
return new ArrayList<>(this.paths);
}
@Override
public boolean isEnabledByDefault() {
return enabledByDefault;
}
@Override
public String toString() {
return "DocPath{" +
"namespace='" + namespace + '\'' +
",paths=" + paths.toString() +
'}';
}
public DocsNameSpaceImpl addPath(Path path) {
this.paths.add(path);
return this;
}
public DocsNameSpaceImpl enabledByDefault() {
this.enabledByDefault=true;
return this;
}
@Override
public Iterator<Path> iterator() {
return this.paths.iterator();
}
public DocsNameSpaceImpl setEnabledByDefault(boolean enabledByDefault) {
this.enabledByDefault=enabledByDefault;
return this;
}
}

View File

@@ -1,5 +1,6 @@
package io.nosqlbench.docsys.api;
import io.nosqlbench.docapi.DocsBinder;
import io.nosqlbench.docsys.endpoints.DocsysMarkdownEndpoint;
/**

View File

@@ -1,5 +1,7 @@
package io.nosqlbench.docsys.api;
import io.nosqlbench.docapi.DocsBinder;
/**
* At runtime, any instances of this service will be used to find
* paths to be hosted as static content.

View File

@@ -1,6 +1,8 @@
package io.nosqlbench.docsys.core;
import io.nosqlbench.docsys.api.*;
import io.nosqlbench.docapi.*;
import io.nosqlbench.docsys.api.DocsysDynamicManifest;
import io.nosqlbench.docsys.api.DocsysStaticManifest;
import java.util.ServiceLoader;
@@ -29,4 +31,6 @@ public class DocsysPathLoader {
}
return docs;
}
}

View File

@@ -1,7 +1,7 @@
package io.nosqlbench.docsys.core;
import io.nosqlbench.docsys.DocsysDefaultAppPath;
import io.nosqlbench.docsys.api.Docs;
import io.nosqlbench.docapi.Docs;
import io.nosqlbench.docsys.api.WebServiceObject;
import io.nosqlbench.docsys.handlers.FavIconHandler;
import io.nosqlbench.nb.annotations.Maturity;

View File

@@ -1,8 +1,8 @@
package io.nosqlbench.docsys.endpoints;
import io.nosqlbench.docsys.api.Docs;
import io.nosqlbench.docsys.api.DocsBinder;
import io.nosqlbench.docsys.api.DocsNameSpace;
import io.nosqlbench.docapi.Docs;
import io.nosqlbench.docapi.DocsBinder;
import io.nosqlbench.docapi.DocsNameSpace;
import io.nosqlbench.docsys.api.WebServiceObject;
import io.nosqlbench.docsys.core.DocsysPathLoader;
import io.nosqlbench.docsys.core.PathWalker;

View File

@@ -1,12 +0,0 @@
## Basic Markdown File
- item 1.
- item 2.
1. numbered item 1
2. numbered item 2
## a list of files:
{{files}}

View File

@@ -1,7 +0,0 @@
---
title: topic1
---
## Topic1 Heading1
This is a topic at `basics/section1/topic1`

View File

@@ -1,5 +0,0 @@
---
title: Section 2 Topic 1
---

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1,8 +0,0 @@
<HTML>
<HEAD>
<TITLE>A title</TITLE>
</HEAD>
<BODY>
Some content in the body.
</BODY>
</HTML>