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

Add hypermedia feature to README #73

Merged
merged 1 commit into from
Jul 9, 2024
Merged

Conversation

koriym
Copy link
Contributor

@koriym koriym commented Jul 9, 2024

Overview

A new section has been added to the README that highlights the hypermedia feature of the tool, which generates class diagrams with clickable links leading directly to the source code. This section also provides guidance on how to enable this feature and integrate the SVG diagrams into HTML while preserving the clickable links.

READMEにハイパーメディアセクションを追加

  • ソースの関係性を見ながらソースの詳細を見れること(=ハイパーメディアであること)がこのプロダクトの大きな魅力であることから、READMEのFeaturesに追加しつつ専用セクションも追加。
  • htmlにimgタグで埋め込むとただの画像になってしまうのと、その回避法が広く知られていないことを前提&考慮して、ハイパーリンクが有効になるobjectembedの例をembedを紹介。
  • その際有効なhtml全文を掲載することで、まるで画像にリンクしているように自然になることと
  • SVGの直リンク全体だと最初の画面で画像全体が見えない。全体像の把握>詳細へとユーザーをナビゲートする方が見る方の理解が自然に進むと考えられることからもhtmlでのCSS指定で100%にするのが有効

extras

追加要素や雑感などコメントします!

  • objectで埋め込むとDOMがJSで操作可能になる。一部のユーザーにとってはその情報が有用かもしれない。
  • private メソッド/プロパティのshow/hideスイッチのサンプルがあるとWebネイティブなSVGの特性がより活かせて面白いかも。
  • 他にも特定のnamespaceだけをshow/hideしたり、特定のケースに注目してのshow/hideなどアイデア次第でより、このダイアグラムが魅力的になると思います!

A new section has been added to the README that highlights the hypermedia feature of the tool, which generates class diagrams with clickable links leading directly to the source code. This section also provides guidance on how to enable this feature and integrate the SVG diagrams into HTML while preserving the clickable links.
@koriym
Copy link
Contributor Author

koriym commented Jul 9, 2024

文章や配置はもちろん変更してもらって構いませんというかしてください!😃

@smeghead
Copy link
Owner

smeghead commented Jul 9, 2024

@koriym
ありがとうございます!!!
「クラス図ハイパーメディア」という視点(観点)は、明確で魅力的ですね。(機能は追加しましたが、自分でこの視点で捉えられていませんでした;)
マージ後に、サンプルページ等の用意をしたいと思います。

@smeghead smeghead merged commit 3e37897 into smeghead:main Jul 9, 2024
5 checks passed
@koriym
Copy link
Contributor Author

koriym commented Jul 9, 2024

サンプル作ってみて

<html lang="en">
<head>
    <title>Ray.Aop Class Diagram</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="This is a class diagram for the Ray.Aop project.">
    <! -- This image was generated by the https://github.com/smeghead/php-class-diagram/ library -->.
    <script>
        var svgDoc = null;
        window.addEventListener("load", function() {
            var svgObject = document.getElementById("svgObject");
            svgObject.addEventListener("load", function() {
                var svgObject = document.getElementById("svgObject");
                svgDoc = svgObject.getSVGDocument();
                if (!svgDoc) {
                    console.error("Failed to load SVG document.");
                }
            });
        });

        function togglePrivateMethods() {
            var svgObject = document.getElementById("svgObject");
            var svgDoc = svgObject.getSVGDocument();
                if (svgDoc) {
                var privateMethods = svgDoc.querySelectorAll(".private-method");
                privateMethods.forEach(method => {
                    if (method.classList.contains("hidden")) {
                        method.classList.remove("hidden");
                    } else {
                        method.classList.add("hidden");
                    }
                });
            } else {
                console.error("SVG document not found or not yet loaded.");
            }
        }
    </script>
    <style>
        object {
             width: 100%;
             height: auto;
         }
    </style>
</head>
<body>
    <object id="svgObject" type="image/svg+xml" data="images/php-class-diagram.svg"></object>
    <button onclick="togglePrivateMethods()">Toggle Private Methods</button>
</body>
</html>

こんな感じで動きそうですけど、動いてません (残骸ですが置いてきます😅 )
svgObject.getSVGDocument()これがどうも取得できなくて、「あーそうだ!これはローカルでやってるからだ!」と以前もやってしまって失敗を思い出したのですが、やっぱりダメでした。😫

@smeghead
Copy link
Owner

@koriym
サンプルページの用意とGitHub Pagesの学習のため、htmlを作成してます。
chromeで、objectタグによる埋め込みとJavaScriptからの操作を試してみました。

https://smeghead.github.io/pages-practice/

PlantUMLの出力するSVGは絶対座標で出力されているようで、要素の表示状態を切り替えてもフレキシブルにレイアウト調整が行なわれる訳ではなさそうでした。(なんとか特定の要素の表示非表示をトグルすることはできました)
また、意味のあるclass名も付いていないようなので、PlantUMLが出力したSVGを素のままでJavaScriptからエレメントを探すのが難しそうでした。

@koriym
Copy link
Contributor Author

koriym commented Jul 12, 2024

なるほどー。なかなか難しいですね。

ところでこれ表示が綺麗ですね。今iPadで見てるんですがレスポンシブで横向きも縦向きも綺麗です😍

@smeghead
Copy link
Owner

SVGのおかげで綺麗なドキュメントを簡単に出せるのは嬉しいですね😅

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.

2 participants