Document nested modules and calling parent functions

オープン
#2,048 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
shell
領域
documentation

調査の方向性

この issue ではドキュメントファイルもテストも特定されていません。まず、ネストされた foo1/foo2/foo3 モジュールの例と、既存の Nushell モジュールドキュメントを確認してください。ネストされたモジュールが親モジュールの関数をどのように解決するのか、示されている親修飾呼び出しがサポートされているかどうか、またユーザーがどのような動作を期待すべきかを文書化してください。

索引モデルが issue の本文から書いたものです。

説明

I can't find any documentation for nested modules and calling parent module functions within a child module.
There seems to be no way to call the outermost parent module's baz function from within a child module. It will always prefer the next parent's baz function.

It is impossible to make the following code print baz in foo1. In my use case the function baz is actually called path, so it not only overwrites the second definition of path in foo1 but also makes the global nushell path module unusable within the bim() function in foo3.

Example code:

export module foo1 {
  export def baz [] { print "baz foo1" }

  export module foo2 {
    export def baz [] { print "baz in foo2" }

    export module foo3 {
      export def bim [] {
        print "bim in foo3"
        
        # this will succeed and call "baz in foo2"
        baz  

        # this will fail with `external foo1 not found`
        # foo1 foo2 baz

        # this will also fail with `external foo1 not found`
        # foo1 baz
      }
    }
  }
}

use foo1
foo1 foo2 foo3 bim # this will print "baz in foo2"
主要言語
TypeScript
スター
258
フォーク
561
平均マージ
3時間 20分
マージ済み PR(30日)
15

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

nushell/nushell.github.io のほかの issue

nushell/nushell.github.io の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。