Coder Social home page Coder Social logo

ember-gen-uml's Introduction

ember-gen-uml

Build and Deploy Coverage Status npm npm version semantic-release Conventional Commits

A CLI to generate PlantUML compatible diagrams from Ember Components source

Usage

1. Install CLI

npm i -g ember-gen-uml

2. Generate UML files

ember-gen-uml app/components --out=/Users/user/Desktop/uml-folder

or using npx:

npx ember-gen-uml app/components --out=/Users/user/Desktop/uml-folder

If you are using PODS layout for components, you need to pass --pods flag:

ember-gen-uml app/components --out=/Users/user/Desktop/uml-folder --pods

3. Generate PNG files or SVG files using plantuml.jar

Download the plantuml.jar from the official website.

java -jar ~/plantuml.jar /User/user/Desktop/uml-folder/**.pu

This will generate PNG files with UML diagrams in the same folder.

To generate in SVG format

java -jar ~/plantuml.jar -tsvg /User/user/Desktop/uml-folder/**.pu

From

For example, this is the es-accordion component from ember-style-guide

import Component from '@ember/component';
import layout from '../templates/components/es-accordion';
import {
  get,
  getProperties,
  set,
} from '@ember/object';
import {
  isPresent,
} from '@ember/utils';
import { computed } from '@ember/object';
import {
  A,
} from '@ember/array';


export default Component.extend({
  layout,

  classNames: ['accordion-group'],
  activeItem: null,
  focusIndex: null,
  accordionItemIndexes: null,

  accordionState: computed('activeItem', 'focusIndex', function() {
    const {
      activeItem,
      focusIndex,
      actions,
    } = getProperties(this, [
      'activeItem',
      'focusIndex',
      'actions',
    ]);

    return {
      activeItem,
      focusIndex,
      setActiveItem: actions.setActiveItem.bind(this),
      setFocusIndex: actions.setFocusIndex.bind(this),
      registerIndex: actions.registerIndex.bind(this),
    };
  }),

  init() {
    this._super(...arguments);

    set(this, 'accordionItemIndexes', []);
  },


  keyDown(e) {
    const keyCode = get(e, 'keyCode');
    const focusIndex = get(this, 'focusIndex');

    if (isPresent(focusIndex)) {
      const targetIndex = this._resolveTargetItemIndex(keyCode);

      set(this, 'activeItem', targetIndex);
    }
  },


  _resolveTargetItemIndex(keyCode) {
    const {
      accordionItemIndexes,
      activeItem,
      focusIndex,
    } = getProperties(this, [
      'accordionItemIndexes',
      'activeItem',
      'focusIndex',
    ]);
    const first = Math.min(...accordionItemIndexes);
    const last = Math.max(...accordionItemIndexes);
    let itemIndexOfIndex = A(accordionItemIndexes).indexOf(activeItem);
    let targetIndex;

    switch (keyCode) {
      case 38:
        if (activeItem === null || itemIndexOfIndex === -1) {
          targetIndex = focusIndex;
        } else if (activeItem === first) {
          targetIndex = last;
        } else {
          itemIndexOfIndex--
          targetIndex = accordionItemIndexes[itemIndexOfIndex];
        }
        break;
      case 40:
        if (activeItem === null || itemIndexOfIndex === -1) {
          targetIndex = focusIndex;
        } else if (activeItem === last) {
          targetIndex = first;
        } else {
          itemIndexOfIndex++
          targetIndex = accordionItemIndexes[itemIndexOfIndex];
        }
        break;
      case 36:
        targetIndex = first;
        break;
      case 35:
        targetIndex = last;
        break;
      case 13:
      case 32:
        if (activeItem !== focusIndex) {
          targetIndex = focusIndex;
        } else {
          targetIndex = null;
        }
        break;
      default:
        targetIndex = activeItem;
    }

    return targetIndex;
  },

  actions: {
    setActiveItem(accordionItemIndex) {
      return set(this, 'activeItem', accordionItemIndex);
    },

    setFocusIndex(accordionItemIndex) {
      set(this, 'focusIndex', accordionItemIndex);
    },

    registerIndex(accordionItemIndex) {
      get(this, 'accordionItemIndexes').push(accordionItemIndex);
    },
  },
});

To

sample uml diagram

CLI Options/Usage

Usage: ember-gen-uml [path...] [options]

Options:

  • -v, --version CLI Version
  • -o, --out Store PlantUML definitions (.pu files) in
  • --pods Enable support for POD style components
  • --ts Enable support for TypeScript components
  • -h, --help output usage information

References

ember-gen-uml's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

chaiwithjai

ember-gen-uml's Issues

Typescript support?

Hey,

I just finished a task on class diagramm two packages of our app (manually) to PlantUML, would've loved some automation here. Our code is written in Typescript (I tried https://github.com/bafolts/tplant) but the results weren't usable.

Any plans to support TS here or a way to integrate something like that?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency prettier to v2.8.8
  • chore(deps): update dependency eslint to v8.57.0
  • fix(deps): update babel monorepo to v7.24.4 (@babel/parser, @babel/plugin-proposal-decorators, @babel/preset-env, @babel/traverse, @babel/types)
  • chore(deps): update actions/checkout action to v4
  • chore(deps): update actions/setup-node action to v4
  • chore(deps): update dependency eslint to v9
  • chore(deps): update dependency eslint-plugin-prettier to v5
  • chore(deps): update dependency prettier to v3
  • fix(deps): update dependency commander to v12
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/main.yml
  • actions/checkout v2
  • actions/setup-node v3
.github/workflows/pull-requests.yml
  • actions/checkout v2
  • actions/setup-node v3
npm
package.json
  • @babel/parser ^7.14.5
  • @babel/plugin-proposal-class-properties ^7.14.5
  • @babel/plugin-proposal-decorators ^7.14.5
  • @babel/preset-env ^7.14.5
  • @babel/traverse ^7.14.5
  • @babel/types ^7.14.5
  • commander ^9.0.0
  • debug ^4.3.1
  • typescript ^4.3.5
  • walk-sync ^3.0.0
  • @semantic-release/changelog 6.0.2
  • @semantic-release/git 10.0.1
  • coveralls 3.1.1
  • eslint 8.36.0
  • eslint-plugin-prettier 4.2.1
  • jest 27.5.1
  • prettier 2.8.6
  • semantic-release 19.0.5
  • node >=12.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.