Rickaym / manim-sideview

A Manim utility extension for Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=Rickaym.manim-sideview
MIT License
99 stars 11 forks source link

load default configuration in an easier way #72

Open Rickaym opened 9 months ago

Rickaym commented 9 months ago

To load the default configuration at the moment:

  1. the default configuration is first instantiated with base values
    // default configurations, these values are set as ./local/manim.cfg.json
    // note only values that are pre-set here are loaded
    export var DEFAULT_CONFIG: ManimConfig & FallbackConfig = {
    media_dir: "",
    video_dir: "",
    images_dir: "",
    quality: "",
    image_name: "",
    frame_rate: "",
    quality_map: {}
    };
  2. the updateFallbackManimCfg is run on extension load time

export function updateFallbackManimCfg( updated: {

}, saveUpdated: boolean = true ) { Object.keys(DEFAULT_CONFIG).forEach((ky) => { if (updated[ky]) { DEFAULT_CONFIG[ky as keyof ManimConfig] = updated[ky]; } });

if (saveUpdated) { fs.writeFile(PATHS.cfgMap!.fsPath, JSON.stringify(DEFAULT_CONFIG), () => {}); } }



Issues:

1. It isn't obvious how the default configuration is loaded at a glance
2. Values loaded from the `manim.cfg.json` file is dependent on the base values set in the initial instantiation