How to use the qsharp.client._execute function in qsharp

To help you get started, we’ve selected a few qsharp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / iqsharp / build / docs / build_docs.py View on Github external
def main(output_dir : str, uid_base : str, package : List[str]):
    output_dir = Path(output_dir)
    # Make the output directory if it doesn't already exist.
    output_dir.mkdir(parents=True, exist_ok=True)

    import qsharp

    print("Adding packages...")
    for package_name in package:
        qsharp.packages.add(package_name)
    
    print("Generating Markdown files...")
    magics = qsharp.client._execute(r"%lsmagic")
    all_magics = {}
    for magic in magics:
        magic_doc = format_as_document(magic, uid_base)
        all_magics[magic_doc.name] = magic_doc
        with open(output_dir / f"{magic_doc.safe_name}.md", 'w', encoding='utf8') as f:
            f.write(magic_doc.content)

    toc_content = format_toc(all_magics)
    with open(output_dir / "toc.yml", 'w', encoding='utf8') as f:
        f.write(toc_content)
    
    index_content = format_index(all_magics, uid_base)
    with open(output_dir / "index.md", 'w', encoding='utf8') as f:
        f.write(index_content)