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

feat(docs): provide docs-custom-elements output targets #2354

Closed
wants to merge 1 commit into from

Conversation

runarberg
Copy link
Contributor

Follows the draft outlined in webcomponents/custom-elements-manifest#8

Closes: #2048

@manucorporat
Copy link
Contributor

Thanks for the PR.

Unfortunately, it's just a self-called standard, we have never been asked for feedback even though our docs-json came first.

In the meantime, stencil supports docs-custom so external generators can be integrated without being part of the core.

We can leave this PR open after there is some traction

@manucorporat
Copy link
Contributor

I guess we could merge it, i am just not sure docs-custom-elements is the correct name.

.map((style) => ({
name: style.name,
description: style.docs,
})),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add cssShadowParts too

@runarberg runarberg force-pushed the docs-custom-elements branch 2 times, most recently from c22e08b to c471830 Compare April 11, 2020 00:36
@runarberg
Copy link
Contributor Author

@manucorporat I am indeed using the docs-custom and it’s working great. In fact this the PR is pretty much a port of the function I put in my stencil.config.ts. I figured it could be useful for the community, if only to link to for other authors that are trying to integrate storybook’s docs addon.

description: style.docs,
})),

cssShadowParts: component.docsTags
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have component parts

@dmartinjs
Copy link

Hello @runarberg

can you share you docs-custom function ?

@runarberg
Copy link
Contributor Author

runarberg commented May 12, 2020

@dmartinjs sure: Note that storybook uses experimental field names compatible with web-component-analizer (cssParts and cssProperties; this standard combat is a mess), so this is a little different from the associated PR:

import { promises as fs } from 'fs';
import { Config } from '@stencil/core';
import { JsonDocs } from '@stencil/core/internal';

async function generateCustomElementsJson(docsData: JsonDocs) {
  const jsonData = {
    version: 1.2,
    tags: docsData.components.map((component) => ({
      name: component.tag,
      path: component.filePath,
      description: component.docs,

      attributes: component.props
        .filter((prop) => prop.attr)
        .map((prop) => ({
          name: prop.attr,
          type: prop.type,
          description: prop.docs,
          defaultValue: prop.default,
          required: prop.required,
        })),

      properties: component.props.map((prop) => ({
        name: prop.name,
        type: prop.type,
        description: prop.docs,
        defaultValue: prop.default,
        required: prop.required,
      })),

      events: component.events.map((event) => ({
        name: event.event,
        description: event.docs,
      })),

      methods: component.methods.map((method) => ({
        name: method.name,
        description: method.docs,
        signature: method.signature,
      })),

      slots: component.slots.map((slot) => ({
        name: slot.name,
        description: slot.docs,
      })),

      cssProperties: component.styles
        .filter((style) => style.annotation === 'prop')
        .map((style) => ({
          name: style.name,
          description: style.docs,
        })),

      cssParts: component.parts.map((part) => ({
        name: part.name,
        description: part.docs,
      })),
    })),
  };

  await fs.writeFile(
    './custom-elements.json',
    JSON.stringify(jsonData, null, 2),
  );
}

export const config: Config = {
  // ...
  outputTargets: [
    // ...
    {
      type: 'docs-custom',
      generator: generateCustomElementsJson,
    },
  ],
};

@dmartinjs
Copy link

Is there some news on this feature ?

@LeeBurton
Copy link

LeeBurton commented Mar 4, 2021

@manucorporat This pull request has been open since April 2020... please can you add this feature?? We have also been waiting on this for a long time, and would rather have this built in than using a third-party dependency.

It is also not great if people invest time an effort in creating PRs to add new functionality and they are not merged fairly quickly or given suggestions for improvement. There is even a further question above from October 2020, asking if there is any news on this feature, and absolutely no response from anyone.

If it takes this long for them to be merged, people will simply stop contributing :-}

@runarberg
Copy link
Contributor Author

@LeeBurton I think this PR is obsolete. The standard in question has changed a little since I opened this PR almost a year ago (see current schema). E.g. now they use cssParts as opposed to the previous cssShadowParts.

This PR would need some work before it could be merged.

@christian-bromann
Copy link
Member

I think this PR is obsolete. The standard in question has changed a little since I opened this PR almost a year ago (see current schema). E.g. now they use cssParts as opposed to the previous cssShadowParts.

Thanks @runarberg for raising the PR.

I will go ahead and close this and propose for anyone interested in this to upvote #2048 so we can gauge interest.

@runarberg runarberg deleted the docs-custom-elements branch June 19, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for web-types/custom-elements-json
5 participants