{"library":"pylint-json2html","title":"Pylint JSON to HTML Converter","description":"pylint-json2html is a Python utility that transforms Pylint's JSON report output into a human-readable HTML document. This library addresses the removal of native HTML output from Pylint since version 1.7. It provides a simple command-line interface to generate presentable code quality reports. The current version is 0.5.0, with releases occurring as needed rather than on a fixed cadence.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install pylint-json2html"],"cli":{"name":"pylint-json2html","version":"usage: pylint-json2html [-h] [-o FILENAME] [-e ENCODING] [-t FILENAME]"}},"imports":[],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import subprocess\nimport os\n\n# Create a dummy Python file to lint\nwith open('my_module.py', 'w') as f:\n    f.write('def my_func():\\n    \"\"\"Missing docstring for function.\"\"\"\\n    pass\\n')\n\n# 1. Run Pylint to generate a JSON report\n# We use a temporary file for Pylint's output, then read it.\n# In a real scenario, you'd pipe directly: `pylint my_module.py --output-format=json | pylint-json2html -o report.html`\ntry:\n    pylint_cmd = ['pylint', 'my_module.py', '--output-format=json', '--msg-template=\"{path}:{line}:{column}: {msg_id}: {msg} ({symbol})\"']\n    pylint_process = subprocess.run(pylint_cmd, capture_output=True, text=True, check=True)\n    pylint_json_output = pylint_process.stdout\n    \n    # Save Pylint's JSON output to a temporary file for demonstration\n    with open('pylint_report.json', 'w') as f:\n        f.write(pylint_json_output)\n\n    # 2. Convert the JSON report to HTML using pylint-json2html\n    # Note: pylint-json2html is typically used via piping, but for programmatic demo, \n    # we simulate input from a file or directly pass content if possible (which it is via stdin for the CLI tool).\n    # For this example, we'll run it as a separate command reading the file.\n    html_cmd = ['pylint-json2html', 'pylint_report.json', '-o', 'pylint_report.html']\n    subprocess.run(html_cmd, check=True)\n\n    print(\"HTML report generated at pylint_report.html\")\n    print(\"JSON report saved at pylint_report.json\")\n\nexcept subprocess.CalledProcessError as e:\n    print(f\"An error occurred during pylint or pylint-json2html execution: {e.stderr}\")\nexcept FileNotFoundError:\n    print(\"Error: Pylint or pylint-json2html command not found. Ensure they are installed and in your PATH.\")\nfinally:\n    # Clean up dummy files\n    if os.path.exists('my_module.py'):\n        os.remove('my_module.py')\n    if os.path.exists('pylint_report.json'):\n        os.remove('pylint_report.json')\n    # The generated HTML report is left for inspection\n    # if os.path.exists('pylint_report.html'):\n    #     os.remove('pylint_report.html') # Uncomment to remove HTML as well","lang":"python","description":"This quickstart demonstrates the typical workflow: first, run Pylint on your code, ensuring its output format is set to JSON. Then, pipe this JSON output to `pylint-json2html`, redirecting its HTML output to a specified file. Alternatively, Pylint's output can be saved to a file and passed as an argument to `pylint-json2html`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}