Skip to content

Commit

Permalink
fix: py script added to modify docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nakul1010 committed Nov 25, 2023
1 parent cebdda1 commit 889506f
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 64 deletions.
48 changes: 0 additions & 48 deletions docs/docs/contracts/src/README.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BitcoinTx
[Git Source](https://github.com/bob-collective/bob/blob/b1d2e344f73495bf4b7b0690a66a25fa4693d0c3/src/bridge/BitcoinTx.sol)
[Git Source](https://github.com/bob-collective/bob/blob/cebdda1540fcce89f17d600bd2a84828c8c85ba6/src/bridge/BitcoinTx.sol)

Allows to reference Bitcoin raw transaction in Solidity.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BridgeState
[Git Source](https://github.com/bob-collective/bob/blob/b1d2e344f73495bf4b7b0690a66a25fa4693d0c3/src/bridge/BridgeState.sol)
[Git Source](https://github.com/bob-collective/bob/blob/cebdda1540fcce89f17d600bd2a84828c8c85ba6/src/bridge/BridgeState.sol)


## Structs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# IRelay
[Git Source](https://github.com/bob-collective/bob/blob/b1d2e344f73495bf4b7b0690a66a25fa4693d0c3/src/bridge/IRelay.sol)
[Git Source](https://github.com/bob-collective/bob/blob/cebdda1540fcce89f17d600bd2a84828c8c85ba6/src/bridge/IRelay.sol)

Contains only the methods needed by tBTC v2. The Bitcoin relay
provides the difficulty of the previous and current epoch. One
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# WitnessTx
[Git Source](https://github.com/bob-collective/bob/blob/b1d2e344f73495bf4b7b0690a66a25fa4693d0c3/src/bridge/WitnessTx.sol)
[Git Source](https://github.com/bob-collective/bob/blob/cebdda1540fcce89f17d600bd2a84828c8c85ba6/src/bridge/WitnessTx.sol)


## State Variables
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# DummyRelay
[Git Source](https://github.com/bob-collective/bob/blob/b1d2e344f73495bf4b7b0690a66a25fa4693d0c3/src/relay/DummyRelay.sol)
[Git Source](https://github.com/bob-collective/bob/blob/cebdda1540fcce89f17d600bd2a84828c8c85ba6/src/relay/DummyRelay.sol)

**Inherits:**

[IRelay](../../bridge/IRelay.sol/interface.IRelay.md)

*DEV-only!*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# LightRelay
[Git Source](https://github.com/bob-collective/bob/blob/b1d2e344f73495bf4b7b0690a66a25fa4693d0c3/src/relay/LightRelay.sol)
[Git Source](https://github.com/bob-collective/bob/blob/cebdda1540fcce89f17d600bd2a84828c8c85ba6/src/relay/LightRelay.sol)

**Inherits:**

Ownable, [ILightRelay](../../relay/LightRelay.sol/interface.ILightRelay.md)

*THE RELAY MUST NOT BE USED BEFORE GENESIS AND AT LEAST ONE RETARGET.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# ILightRelay
[Git Source](https://github.com/bob-collective/bob/blob/b1d2e344f73495bf4b7b0690a66a25fa4693d0c3/src/relay/LightRelay.sol)
[Git Source](https://github.com/bob-collective/bob/blob/cebdda1540fcce89f17d600bd2a84828c8c85ba6/src/relay/LightRelay.sol)

**Inherits:**

[IRelay](../../bridge/IRelay.sol/interface.IRelay.md)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RelayUtils
[Git Source](https://github.com/bob-collective/bob/blob/b1d2e344f73495bf4b7b0690a66a25fa4693d0c3/src/relay/LightRelay.sol)
[Git Source](https://github.com/bob-collective/bob/blob/cebdda1540fcce89f17d600bd2a84828c8c85ba6/src/relay/LightRelay.sol)


## Functions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Epoch
[Git Source](https://github.com/bob-collective/bob/blob/b1d2e344f73495bf4b7b0690a66a25fa4693d0c3/src/relay/LightRelay.sol)
[Git Source](https://github.com/bob-collective/bob/blob/cebdda1540fcce89f17d600bd2a84828c8c85ba6/src/relay/LightRelay.sol)


```solidity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Bridge
[Git Source](https://github.com/bob-collective/bob/blob/b1d2e344f73495bf4b7b0690a66a25fa4693d0c3/src/swap/Bridge.sol)
[Git Source](https://github.com/bob-collective/bob/blob/cebdda1540fcce89f17d600bd2a84828c8c85ba6/src/swap/Bridge.sol)


## State Variables
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BtcMarketPlace
[Git Source](https://github.com/bob-collective/bob/blob/b1d2e344f73495bf4b7b0690a66a25fa4693d0c3/src/swap/Btc_Marketplace.sol)
[Git Source](https://github.com/bob-collective/bob/blob/cebdda1540fcce89f17d600bd2a84828c8c85ba6/src/swap/Btc_Marketplace.sol)


## State Variables
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# MarketPlace
[Git Source](https://github.com/bob-collective/bob/blob/b1d2e344f73495bf4b7b0690a66a25fa4693d0c3/src/swap/Marketplace.sol)
[Git Source](https://github.com/bob-collective/bob/blob/cebdda1540fcce89f17d600bd2a84828c8c85ba6/src/swap/Marketplace.sol)


## State Variables
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BobWrappedBtc
[Git Source](https://github.com/bob-collective/bob/blob/b1d2e344f73495bf4b7b0690a66a25fa4693d0c3/src/swap/Wrapped.sol)
[Git Source](https://github.com/bob-collective/bob/blob/cebdda1540fcce89f17d600bd2a84828c8c85ba6/src/swap/Wrapped.sol)

**Inherits:**
ERC20, ERC20Burnable, Ownable
Expand Down
63 changes: 63 additions & 0 deletions python_script/refactor_doc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import os
import re

# Function to parse the Inherits line in the Markdown content
def parse_inherits(md_content):
inherits_match = re.search(r'\*\*Inherits:\*\*\s*([\s\S]*?)\n', md_content)
if inherits_match:
inheritances = inherits_match.group(1).strip()
return inheritances
return None

# Function to replace paths inside brackets with empty brackets
def replace_paths_with_empty_brackets(line):
def replace_path(match):
default_path = 'docs/docs/src'
path = default_path + match.group(0)[1:-1] # Remove parentheses
start = "docs/docs/src/src/X/X/"
relative_path = os.path.relpath(path, start)
print(f"Original Path: {relative_path}")
return '(' + relative_path + ')'
return re.sub(r'\([^)]+\)', replace_path, line)

# Function to process a single Markdown file
def process_md_file(file_path):
with open(file_path, 'r') as file:
md_content = file.read()

# Parse Inherits line
inherits = parse_inherits(md_content)

# Modify the Inherits line
if inherits:
modified_inherits = replace_paths_with_empty_brackets(inherits)
md_content = md_content.replace(inherits, modified_inherits)

# Write the modified content back to the original file
with open(file_path, 'w') as file:
file.write(md_content)

print(f"File modified: {file_path}")

# Check if the file name is README.md or SUMMARY.md and delete it
file_name = os.path.basename(file_path)
if file_name.lower() in ['readme.md', 'summary.md']:
os.remove(file_path)
print(f"Deleted file: {file_path}")

# Main function to process all Markdown files in a directory and its subdirectories
def process_all_md_files(directory):
for root, dirs, files in os.walk(directory):
for file in files:
if file.endswith('.md'):
file_path = os.path.join(root, file)
process_md_file(file_path)

if __name__ == "__main__":
# Specify the directory path
directory_path = '../docs/docs/contracts/src'

# Process all Markdown files in the specified directory and its subdirectories
process_all_md_files(directory_path)

print("All Markdown files in the directory processed.")

0 comments on commit 889506f

Please sign in to comment.