microsoft / microsoft/pxt

Category comments do not work when generating from simulator

Open
#10,216 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.3k
Forks
641
Avg merge
12h 4m
Merged PRs (30d)
57

Description

Bug Template

Describe the bug

When using auto-generation from the simulator, the category comments for namespaces do not work, as they are simply ignored.

To Reproduce

  1. Configure core lib to use auto-generated blocks (create sims.d.ts file, add it to pxt.json).

  2. Create a simulator file that exposes some blocks in a category:

    /**
     * Provides access to basic micro:bit functionality.
     */
    //% color=#1E90FF weight=116 icon="\uf00a"
    namespace pxsim.basic {
        /**
         * Repeat the code forever in the background
         * @param body code to execute
         */
        //% help=functions/forever weight=55
        //% blockId=device_forever block="forever" afterOnStart=true
        export function forever (body: RefAction): void {
            thread.forever(body)
        }
    
        /**
         * Pause for the specified time in milliseconds
         * @param ms how long to pause for, eg. 100, 200, 500, 1000, 2000
         */
        //% help=functions/pause weight=54
        //% blockId=device_pause block="pause (ms) %pause"
        export function pause (ms: number): void {
            if (isNaN(ms)) ms = 20
            thread.pause(ms)
        }
    }
    
  3. See that sims.d.ts does not contain the category comment:

    // Auto-generated from simulator. Do not edit.
    declare namespace basic {
        /**
         * Repeat the code forever in the background
         * @param body code to execute
         */
        //% help=functions/forever weight=55
        //% blockId=device_forever block="forever" afterOnStart=true
        //% shim=basic::forever
        function forever(body: () => void): void;
    
        /**
         * Pause for the specified time in milliseconds
         * @param ms how long to pause for, eg. 100, 200, 500, 1000, 2000
         */
        //% help=functions/pause weight=54
        //% blockId=device_pause block="pause (ms) %pause"
        //% shim=basic::pause
        function pause(ms: number): void;
    
    }
    
    // Auto-generated. Do not edit. Really.
    

Expected behavior

The category comment should be present and applied correctly in the editor.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue using the auto-generation setup from makecode.com/simshim: configure the core library, add sims.d.ts to pxt.json, and expose a namespaced block in the simulator file. Start by tracing the generator that produces sims.d.ts and compare its handling of namespace comments with function comments. Done means the category comment is emitted in sims.d.ts and applied correctly in the editor.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.