次のコードブロックをどのようにコメントアウトできますか? [閉鎖]

次のコードブロックをどのようにコメントアウトできますか? [閉鎖]

私が持っているもの:

...
    {if $dockerPipelinesEnabled}
        {call aui.buttons.button}
            {param text: getText('deployment.environment.docker.button') /}
            {param tagName: 'a' /}
            {param id: 'configureEnvironmentDocker' + $id /}
            {param extraAttributes: [ 'href': contextPath() + '/deploy/config/configureEnvironmentDocker.action?environmentId=' + $id ] /}
        {/call}
    {/if}

    {call aui.buttons.button}
        {param text: getText('deployment.project.environment.agents') /}
        {param tagName: 'a' /}
        {param id: 'configureEnvironmentAgents' + $id /}
        {param extraAttributes: [ 'href': contextPath() + '/deploy/config/configureEnvironmentAgents.action?environmentId=' + $id ] /}
    {/call}

    {call widget.override.aui.badgeButton}
        {param text: getText('environment.notifications') /}
        {param tagName: 'a' /}
        {param id: 'configureDeploymentsNotifications' + $id /}
        {param extraAttributes: [ 'href': contextPath() + '/deploy/config/configureEnvironmentNotifications.action?environmentId=' + $id ] /}
        {param badgeText: $notificationsNumberString /}
    {/call}
...

私が望むもの:

...
    {if $dockerPipelinesEnabled}
        {call aui.buttons.button}
            {param text: getText('deployment.environment.docker.button') /}
            {param tagName: 'a' /}
            {param id: 'configureEnvironmentDocker' + $id /}
            {param extraAttributes: [ 'href': contextPath() + '/deploy/config/configureEnvironmentDocker.action?environmentId=' + $id ] /}
        {/call}
    {/if}

  /**  {call aui.buttons.button}
        {param text: getText('deployment.project.environment.agents') /}
        {param tagName: 'a' /}
        {param id: 'configureEnvironmentAgents' + $id /}
        {param extraAttributes: [ 'href': contextPath() + '/deploy/config/configureEnvironmentAgents.action?environmentId=' + $id ] /}
    {/call} */

    {call widget.override.aui.badgeButton}
        {param text: getText('environment.notifications') /}
        {param tagName: 'a' /}
        {param id: 'configureDeploymentsNotifications' + $id /}
        {param extraAttributes: [ 'href': contextPath() + '/deploy/config/configureEnvironmentNotifications.action?environmentId=' + $id ] /}
        {param badgeText: $notificationsNumberString /}
    {/call}
...

複数のステートメントで一意の行に注釈を付けることができますが、そのコードブロックには他のブロックに存在する共通の行があります。

許可される形式は次のとおりです。

/**  {call aui.buttons.button}
        {param text: getText('deployment.project.environment.agents') /}
        {param tagName: 'a' /}
        {param id: 'configureEnvironmentAgents' + $id /}
        {param extraAttributes: [ 'href': contextPath() + '/deploy/config/configureEnvironmentAgents.action?environmentId=' + $id ] /}
    {/call} */

または:

 /**  {call aui.buttons.button} */
 /**    {param text: getText('deployment.project.environment.agents') /} */
 /**       {param tagName: 'a' /} */
 /**       {param id: 'configureEnvironmentAgents' + $id /} */
 /**       {param extraAttributes: [ 'href': contextPath() + '/deploy/config/configureEnvironmentAgents.action?environmentId=' + $id ] /}
 /**   {/call} */

編集する

私はsedandを使ってこの問題を解決しようとしましたが、awkややマイナーなようですgrep

grep --invert-match "$(grep -B 1 -A 4 .*deployment.project.environment.agents <path-to-file>

grep一致をブロックとして扱う代わりに、各行が削除され、結果が破損するように見えます。

修正する

完全なファイルは次のとおりですここ(面白い内容は一番下にあります)

このファイルでは、上記のセクションを次のようにコメントアウトしたいと思います。許可される形式)。

複数の場所に表示されるため、{call aui.buttons.button}マーカーだけでは不十分です。コードブロックを削除することも許可されます。

ベストアンサー1

努力するsed

sed '/{call/ {:L; N; /{\/call/!bL; /deployment.project/ {s/^/\/**/; s/$/*\//}} ' file
    {if $dockerPipelinesEnabled}
        {call aui.buttons.button}
            {param text: getText('deployment.environment.docker.button') /}
            {param tagName: 'a' /}
            {param id: 'configureEnvironmentDocker' + $id /}
            {param extraAttributes: [ 'href': contextPath() + '/deploy/config/configureEnvironmentDocker.action?environmentId=' + $id ] /}
        {/call}
    {/if}

/**    {call aui.buttons.button}
        {param text: getText('deployment.project.environment.agents') /}
        {param tagName: 'a' /}
        {param id: 'configureEnvironmentAgents' + $id /}
        {param extraAttributes: [ 'href': contextPath() + '/deploy/config/configureEnvironmentAgents.action?environmentId=' + $id ] /}
    {/call}*/

    {call widget.override.aui.badgeButton}
        {param text: getText('environment.notifications') /}
        {param tagName: 'a' /}
        {param id: 'configureDeploymentsNotifications' + $id /}
        {param extraAttributes: [ 'href': contextPath() + '/deploy/config/configureEnvironmentNotifications.action?environmentId=' + $id ] /}
        {param badgeText: $notificationsNumberString /}
    {/call}

各出会いごとに線が見つかる{call}までパターン空間に線を集めます(ただし、mosvyの注意事項を参照)。{/call}次に、ターゲットパターンがパターンスペースにある場合は、行の先頭/**と末尾に追加します。*/

おすすめ記事