{"push_id":800390039,"size":1,"distinct_size":1,"ref":"refs/heads/add-global-refs","head":"c2bf0e9b4fd7d1f2ef0c8de7fa0ef5006a21d75d","before":"c34b640aca2f1db3fa71cb745ac5dcb861047d8d","commits":[{"sha":"c2bf0e9b4fd7d1f2ef0c8de7fa0ef5006a21d75d","author":{"email":"a0eed57aaedf007a763cbac2dd65f90f9fe7ec18@gmail.com","name":"Elliot Ronaghan"},"message":"Add top level labels to all .rst READMEs\n\nWe've decided to use top-level labels to do cross-referencing. Using :doc: with\nrelative file names proved to be pretty fragile, so we've decided to use :ref:\nwhere each .rst file has a top level label defined as 'readme-< file name >.\nWe're prefixing with the \"readme-\" because these are global labels so we want\nsome way to make sure they're unique.\n\ne.g. to reference platforms/README.cray.rst, just do \":ref:`readme-cray`\"\n\nI used the following script to do this (couldn't get it in bash quick enough):\n\n```python\n#!/usr/bin/env python\n\nimport fnmatch\nimport os\nimport re\n\nchpl_home = os.getenv('CHPL_HOME')\ndocs_dir = os.path.join(chpl_home, 'doc', 'release')\n\nmatches = []\nfor root, dirnames, filenames in os.walk(docs_dir):\n  for filename in fnmatch.filter(filenames, '*.rst'):\n      matches.append(os.path.join(root, filename))\n\nfor match in matches:\n    lines = []\n    with open(match, 'r') as f:\n        lines = f.readlines()\n        fname = os.path.basename(match)\n        ref_to_file = re.sub('^README\\.', '', fname)\n        ref_to_file = re.sub('\\.rst$', '', ref_to_file)\n        ref_to_file = '.. _readme-'+ref_to_file+':\\n\\n'\n        lines.insert(0, ref_to_file)\n    with open(match, 'w') as f:\n        f.writelines(lines)\n```","distinct":true,"url":"https://api.github.com/repos/ronawho/chapel/commits/c2bf0e9b4fd7d1f2ef0c8de7fa0ef5006a21d75d"}]}