Skip to content

Commit

Permalink
Fixes docu script
Browse files Browse the repository at this point in the history
  • Loading branch information
walmazacn committed Nov 13, 2024
2 parents 6b16a2c + 3262bdd commit c8a1aed
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 69 deletions.
122 changes: 122 additions & 0 deletions docs/luigi-element-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<!-- meta
{
"node": {
"label": "Luigi Element API",
"category": {
"label": "API Reference",
"collapsible": true
},
"metaData": {
"categoryPosition": 6,
"position": 5
}
}
}
meta -->

# Luigi Element

The `LuigiElement` class is a base class for building web component micro frontends within the Luigi framework. It provides essential functionality for rendering and managing the lifecycle of web components.

## Example Usage

To create a custom web component, extend `LuigiElement` and implement the required methods such as `render()`, `afterInit()`, and `onContextUpdate()`.

```js
class MyComponent extends LuigiElement {
render(ctx) {
return `<div>Hello, ${ctx.user.name}!</div>`;
}

afterInit(ctx) {
console.log('MyComponent initialized with context:', ctx);
}

onContextUpdate(ctx) {
console.log('Context updated:', ctx);
}
}
```

The html function allows for creating HTML templates with interpolated values.

```js
const name = 'World';
const template = html`<p>Hello, ${name}!</p>`;
console.log(template); // Output: <p>Hello, World!</p>
```

## API Reference

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### LuigiElement

**Extends HTMLElement**

Base class for Luigi web component micro frontends.

#### Parameters

* `options` **Options**

#### afterInit

Override to execute logic after initialization of the web component, i.e.
after internal rendering and all context data set.

##### Parameters

* `ctx` **any** The context object passed by luigi core

Returns **void**

#### render

Override to return the html template string defining the web component view.

##### Parameters

* `ctx` **any** The context object passed by luigi core

Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**

#### update

Override to execute logic after an attribute of this web component has changed.

Returns **void**

#### onContextUpdate

Override to execute logic when a new context object is set.

##### Parameters

* `ctx` **any** The new context object passed by luigi core

Returns **void**

#### querySelector

* **See**: ParentNode.querySelector

Query selector operating on shadow root.

##### Parameters

* `selector` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**

Returns **([HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element) | null)**

### html

Html string processing according to luigi functionality.
Also useful in combination with LitElement VS Code plugins.

#### Parameters

* `literal` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The literal to process.
* `keys` **...[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<any>**

Returns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Returns the processed literal.
1 change: 1 addition & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ nav:
- API Reference:
- Luigi Core API: luigi-core-api.md
- Luigi Client API: luigi-client-api.md
- Luigi Element API: luigi-element-api.md
- Advanced:
- Advanced scenarios: advanced-scenarios.md
- Core/Client Communication: communication.md
Expand Down
108 changes: 42 additions & 66 deletions scripts/package-lock.json

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

6 changes: 4 additions & 2 deletions scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "luigi-scripts-private",
"private": true,
"scripts": {
"docu": "npm run docu:container && npm run docu:client && npm run docu:core",
"docu": "npm run docu:container && npm run docu:client && npm run docu:core && npm run docu:element",
"docu:generate:section": "npm run docu:client:generate:section && npm run docu:core:generate:sections",
"docu:container": "npm run docu:container:validate && npm run docu:container:generate:sections",
"docu:container:validate": "documentation lint ../container/typings/LuigiContainer.svelte.d.ts ../container/typings/LuigiCompoundContainer.svelte.d.ts",
Expand All @@ -12,6 +12,7 @@
"docu:client": "npm run docu:client:validate && npm run docu:client:generate:section",
"docu:client:generate:section": "documentation readme --shallow ../client/src/lifecycleManager.ts ../client/luigi-client-wc-docu-mixin.ts ../client/src/linkManager.ts ../client/src/splitViewHandle.ts ../client/src/storageManager.ts ../client/src/uxManager.ts --parse-extension ts -f md --readme-file=../docs/luigi-client-api.md --section=\"API Reference\" --markdown-toc=false --github=false --sort-order=alpha",
"docu:client:validate": "documentation lint --shallow ../client/src/lifecycleManager.ts ../client/luigi-client-wc-docu-mixin.ts ../client/src/linkManager.ts ../client/src/splitViewHandle.ts ../client/src/storageManager.ts ../client/src/uxManager.ts",
"docu:element": "documentation readme --shallow ../client/src/luigi-element.ts --parse-extension ts -f md --readme-file=../docs/luigi-element-api.md --section=\"API Reference\" --markdown-toc=false --quiet --github false",
"docu:core": "npm run docu:core:validate && npm run docu:core:generate:sections",
"docu:core:validate": "documentation lint --shallow ../core/src/core-api/config.js ../core/src/core-api/elements.js ../core/src/core-api/auth.js ../core/src/core-api/navigation.js ../core/src/core-api/i18n.js ../core/src/core-api/custom-messages.js ../core/src/core-api/ux.js ../core/src/core-api/globalsearch.js ../core/src/core-api/theming.js ../core/src/core-api/featuretoggles.js",
"docu:core:generate:sections": "npm run docu:core:generate:config && npm run docu:core:generate:dom-elements && npm run docu:core:generate:auth && npm run docu:core:generate:navigation && npm run docu:core:generate:i18n && npm run docu:core:generate:custom-messages && npm run docu:core:generate:ux && npm run docu:core:generate:globalsearch && npm run docu:core:generate:theming && npm run docu:core:generate:featuretoggles",
Expand All @@ -32,6 +33,7 @@
"@babel/cli": "^7.24.8",
"@babel/core": "^7.24.9",
"@babel/node": "^7.24.8",
"@babel/parser": "^7.26.2",
"@babel/preset-env": "^7.24.8",
"async-request": "^1.2.0",
"cli-color": "^2.0.0",
Expand All @@ -44,4 +46,4 @@
"engines": {
"node": ">=18.19.1"
}
}
}
3 changes: 2 additions & 1 deletion website/docs/src/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ body {

// API Function names
&.page-luigi-core-api,
&.page-luigi-client-api {
&.page-luigi-client-api,
&.page-luigi-element-api {
h4 {
margin-top: 35px;
display: inline-block;
Expand Down

0 comments on commit c8a1aed

Please sign in to comment.