-
Notifications
You must be signed in to change notification settings - Fork 327
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
Prepare API generator for automatic check #12175
Conversation
Or for a module that contains only imports.
engine/runtime-compiler/src/main/java/org/enso/compiler/docs/DocsGenerate.java
Outdated
Show resolved
Hide resolved
public static <File> File defaultOutputDir(org.enso.pkg.Package<File> pkg) { | ||
var fs = pkg.fileSystem(); | ||
var docs = fs.getChild(pkg.root(), "docs"); | ||
var api = fs.getChild(docs, "api"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could select the directory based on the "type of documentation" - e.g. api
for --docs=api
and md
for --docs
or --docs=md
@@ -8,7 +8,7 @@ add_specs suite_builder = suite_builder.group "Standard.Base Signature Checks" g | |||
setup = Api_Setup.create 'Standard' 'Base' [ "--docs=api" ] | |||
|
|||
group_builder.specify "Standard.Base.Meta" <| | |||
snapshot = setup.api_dir / "Standard" / "Base" / "Meta.md" | |||
snapshot = setup.api_dir / "Meta.md" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skipping namespace
and name
from the directory structure? That is probably good idea. CCing @radeusgd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is that the directory hierarchy under docs/api
should follow the one in src
. It is tested in
Lines 282 to 312 in 30904f6
@Test | |
public void generatedSignaturesForProject_HasSameDirectoryHierarchyAsSources() | |
throws IOException { | |
var projName = "Proj"; | |
var modules = | |
Set.of( | |
new SourceModule(QualifiedName.fromString("Main"), "main = 42"), | |
new SourceModule(QualifiedName.fromString("Subdir.Submodule"), "submodule = 42")); | |
var projDir = TEMP.newFolder(projName); | |
ProjectUtils.createProject(projName, modules, projDir.toPath()); | |
ProjectUtils.generateProjectDocs( | |
"api", | |
ContextUtils.defaultContextBuilder(), | |
projDir.toPath(), | |
ctx -> { | |
var ensoCtx = ContextUtils.leakContext(ctx); | |
var pkg = | |
ensoCtx | |
.getPackageRepository() | |
.getPackageForLibrary(LibraryName.apply("local", projName)); | |
assertThat(pkg.isDefined(), is(true)); | |
var signatureOutDir = DocsGenerate.defaultOutputDir(pkg.get()); | |
assertThat( | |
"Default output dir for signatures was created", signatureOutDir.exists(), is(true)); | |
var srcDir = pkg.get().sourceDir(); | |
assertThat(srcDir.resolve("Main.enso").exists(), is(true)); | |
assertThat(signatureOutDir.resolve("Main.md").exists(), is(true)); | |
assertThat(srcDir.resolve("Subdir").resolve("Submodule.enso").exists(), is(true)); | |
assertThat(signatureOutDir.resolve("Subdir").resolve("Submodule.md").exists(), is(true)); | |
}); | |
} |
Pull Request Description
First step of #10507. Preparations for the
Standard.Base
API check job that will be introduced in a follow-up PR. In this PR, the functionality of DocsEmitSignatures is modified and tested such that its generated signatures for a module is ready for usage in the API check job. Most importantly, the signatures are sorted.Sorting of the generated signatures prevents future false-positive failures of the API check job when somebody just reorders items in a module.
Important Notes
Further modifications to DocsEmitSignatures:
docs/api
corresponds to the directory structure insrc
.docs/api/Standard/Base/Any.md
but now it is justdocs/api/Any.md
(which was generated fromsrc/Any.enso
).Example output is:
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
TypeScript,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
or the Snowflake database integration, a run of the Extra Tests has been scheduled.