Skip to content
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

Do not merge/js doc #1164

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"build-webc:ts": "pnpm --filter ui5-tsapp-webc build",
"build-cds": "pnpm --filter cds-bookshop build",
"build-bookshop": "pnpm --filter ui5-bookshop-viewer build",
"jsdoc-lib:ts": "pnpm --filter ui5-tslib jsdoc",
"clean": "pnpm --filter ui5-app clean",
"dev": "pnpm --filter ui5-app dev",
"dev:ts": "pnpm --filter ui5-tsapp dev",
Expand Down
59 changes: 59 additions & 0 deletions packages/ui5-tooling-modules/lib/task-jsdoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const path = require("path");
const { existsSync } = require("fs");
const WebComponentRegistry = require("./utils/WebComponentRegistry");

/**
* Custom task to create the UI5 AMD-like bundles for used ES imports from node_modules.
*
* @param {object} parameters Parameters
* @param {module:@ui5/logger/Logger} parameters.log Logger instance
* @param {module:@ui5/fs/DuplexCollection} parameters.workspace DuplexCollection to read and write files
* @param {object} parameters.taskUtil Specification Version dependent interface to a
* [TaskUtil]{@link module:@ui5/builder.tasks.TaskUtil} instance
* @param {object} parameters.options Options
* @param {string} parameters.options.projectName Project name
* @param {string} [parameters.options.projectNamespace] Project namespace if available
* @param {object} [parameters.options.configuration] Task configuration if given in ui5.yaml
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
*/
module.exports = async function ({ log, workspace, taskUtil /*, options */ }) {
// determine the current working directory and the package.json path
let cwd = taskUtil.getProject().getRootPath() || process.cwd();
let pkgJsonPath = path.join(cwd, "package.json");

// if the package.json is not in the root of the project, try to find it
// in the npm_package_json environment variable (used by npm scripts)
if (!existsSync(pkgJsonPath)) {
pkgJsonPath = process.env.npm_package_json;
cwd = path.dirname(pkgJsonPath);
}
const pkgJson = require(pkgJsonPath);

for (const dep of Object.keys(pkgJson.dependencies)) {
console.log("XXX", WebComponentRegistry.getPackage(dep));
}

const apiJsons = await workspace.byGlob("/**/designtime/api.json");
if (apiJsons.length === 1) {
const apiJson = JSON.parse(await apiJsons[0].getString());
console.log("API JSON");
apiJson.__MODIFIED = "HURRAY";
apiJsons[0].setString(JSON.stringify(apiJson, null, 2));
await workspace.write(apiJsons[0]);
}

log.info("Hello World!");
};

/**
* Callback function to define the list of required dependencies
*
* @returns {Promise<Set>}
* Promise resolving with a Set containing all dependencies
* that should be made available to the task.
* UI5 Tooling will ensure that those dependencies have been
* built before executing the task.
*/
module.exports.determineRequiredDependencies = async function () {
return new Set(); // dependency resolution uses Nodes' require APIs
};
9 changes: 9 additions & 0 deletions packages/ui5-tooling-modules/ui5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@ kind: extension
type: task
task:
path: lib/task.js
---
# https://sap.github.io/ui5-tooling/pages/extensibility/CustomTasks/
specVersion: "3.0"
metadata:
name: ui5-tooling-modules-task-jsdoc
kind: extension
type: task
task:
path: lib/task-jsdoc.js
69 changes: 69 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions showcases/ui5-tslib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"scripts": {
"clean": "rimraf dist coverage",
"build": "ui5 build --clean-dest",
"jsdoc": "ui5 build jsdoc --exclude-task buildThemes",
"dev": "ui5 serve --port 8080 -o test-resources/ui5/ecosystem/demo/tslib/Example.html",
"start": "ui5 serve --port 8080 -o test-resources/ui5/ecosystem/demo/tslib/Example.html --config ui5-dist.yaml",
"testsuite": "ui5 serve --open test-resources/ui5/ecosystem/demo/tslib/qunit/testsuite.qunit.html",
Expand All @@ -24,6 +25,10 @@
"url": "https://github.com/ui5-community/ui5-ecosystem-showcase.git",
"directory": "showcases/ui5-tslib"
},
"dependencies": {
"@ui5/webcomponents-base": "2.6.2",
"@ui5/webcomponents": "2.6.2"
},
"devDependencies": {
"@types/openui5": "1.129.0",
"@ui5/cli": "^4.0.9",
Expand Down
31 changes: 31 additions & 0 deletions showcases/ui5-tslib/src/Button.gen.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { PropertyBindingInfo } from "sap/ui/base/ManagedObject";
import { $WebComponentSettings } from "sap/ui/core/webc/WebComponent";

declare module "./Button" {

/**
* Interface defining the settings object used in constructor calls
*/
interface $ButtonSettings extends $WebComponentSettings {

/**
* The text to display.
*/
specialText?: string | PropertyBindingInfo;
}

export default interface Button {

// property: specialText

/**
* The text to display.
*/
getSpecialText(): string;

/**
* The text to display.
*/
setSpecialText(specialText: string): this;
}
}
46 changes: 46 additions & 0 deletions showcases/ui5-tslib/src/Button.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*!
* ${copyright}
*/

// Provides control ui5.ecosystem.demo.tslib.Button.
// TODO: for interface generation, the control must extend a WebComponent base class and
// the WebCButton base class used here is really a UI5 Web Component and no control!
import WebCButton from "@ui5/webcomponents/dist/Button";
//import WebComponent from "sap/ui/core/webc/WebComponent";

/**
* Constructor for a new <code>ui5.ecosystem.demo.tslib.Button</code> control.
*
* Some class description goes here.
* @extends @ui5.webcomponents.dist.Button
*
* @author OpenUI5 Team
* @version ${version}
*
* @constructor
* @public
* @name ui5.ecosystem.demo.tslib.Button
*/
export default class Button extends WebCButton {
// The following three lines were generated and should remain as-is to make TypeScript aware of the constructor signatures
constructor(id?: string | $ButtonSettings);
constructor(id?: string, settings?: $ButtonSettings);
constructor(id?: string, settings?: $ButtonSettings) {
super(id, settings);
}

static readonly metadata = {
library: "ui5.ecosystem.demo.tslib",
tag: WebCButton.getMetadata().getTag(),
properties: {
/**
* The text to display.
*/
specialText: {
type: "string",
group: "Data",
defaultValue: null,
},
},
};
}
4 changes: 4 additions & 0 deletions showcases/ui5-tslib/src/util/capitalize.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*!
* ${copyright}
*/

import capitalize from "sap/base/strings/capitalize";

export default function (stringToHash: string): string {
Expand Down
11 changes: 11 additions & 0 deletions showcases/ui5-tslib/test/Example.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import { ExampleColor } from "ui5/ecosystem/demo/tslib/library";
import Example from "ui5/ecosystem/demo/tslib/Example";
import Button from "ui5/ecosystem/demo/tslib/Button";

// create a new instance of the Example control and
// place it into the DOM element with the id "content"
new Example({
text: "Example",
color: ExampleColor.Highlight,
}).placeAt("content");

/* TODO:
* - Transitive dependencies are not considered (only if added to package.json and tsconfig.json)
* - 2.7.0 introduces problems with lazy loading of the JSX runtime
*/

// eslint-disable-next-line @typescript-eslint/no-unsafe-call
new Button({
text: "Hello World",
}).placeAt("content");
3 changes: 2 additions & 1 deletion showcases/ui5-tslib/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"rootDir": "./",
"paths": {
"ui5/ecosystem/demo/tslib/*": ["./src/*"]
}
},
"types": ["@types/openui5", "@types/qunit", "@ui5/webcomponents", "@ui5/webcomponents-base"]
},
"include": ["./src/**/*", "./test/**/*"]
}
Loading
Loading