Skip to content

Commit

Permalink
docs: update markdown links from inline to reference (footnote) style (
Browse files Browse the repository at this point in the history
…#1116)

* Clean up links in contributing

* done: CONTRIBUTING.md

* done: INSTALL.md

* done: User-Mantual-For-Project-Managers.md

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Moving script file to a new directory

* move new script file to a new directory

* deleted superfluous XINSTALL copy.md

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
cordovez and pre-commit-ci[bot] authored Jan 19, 2024
1 parent 60399ca commit 512b130
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 54 deletions.
31 changes: 19 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ If you have **any** questions, please ask!

You can see an overview of the project and the process we have gone through in
developing FMTM so far in these
[slides](<https://docs.google.com/presentation/d/>
1UrBG1X4MXwVd8Ps498FDlAYvesIailjjPPJfR_B4SUs/edit#slide=id.g15c1f409958_0_0)
[slides][1]

Furthermore, there are many ways to contribute to the
**Field Mapping Tasking Manager (FMTM)**, which includes:
Expand All @@ -39,15 +38,15 @@ Skills with the following would be beneficial:
- CI/CD workflows

Our latest task board can be found
[here](https://github.com/orgs/hotosm/projects/22).
[here][2].

## Report bugs and suggest improvements

The [issue queue](https://github.com/hotosm/fmtm/issues) is the best way to get
The [issue queue][3] is the best way to get
started. There are issue templates for BUGs and FEATURES that you can use, you
could also create your own. Once you have submitted an issue, it will be
assigned one label from the following
[label categories](<<https://github.com/hotosm/fmtm/labels>).
[label categories][4].
If you are wondering where to start, you can filter by the
**good first issue label**.

Expand All @@ -62,8 +61,7 @@ Github, please reach out to us via our Slack **#geospatial-tech-and-innovation**

### Workflow

We operate the "Fork & Pull" model explained at [About Pull
Requests](https://help.github.com/articles/about-pull-requests/)
We operate the "Fork & Pull" model explained at [About Pull Requests][5]

You should fork the project into your own repo, create a topic branch
there and then make one or more pull requests back to the repository.
Expand Down Expand Up @@ -94,8 +92,7 @@ community of people involved with this project.

### Documentation

Project documentation should be in [Markdown
format](https://www.markdownguide.org/), and in a _docs_
Project documentation should be in [Markdown format][6], and in a _docs_
subdirectory. While it is possible to use HTML in Markdown documents
for tables and images, it is prefered to use the Markdown style as
it's much easier to read.
Expand All @@ -110,20 +107,30 @@ to be easily reused and run either standalone, or part of a REST API
backend. Code that is not designed to be run standalone can have a
main function to do simple testing during development. That test code
should be moved to a standalone test case when possible.
[Pytest](https://pytest.org/) is used as the test framework for
[Pytest][7] is used as the test framework for
standalone test cases.

Code follows a [CamelCase](https://en.wikipedia.org/wiki/Camel_case)
Code follows a [CamelCase][8]
style. Classes use an Upper Case for the first word, method use a
lower case for the first word. Variable names are all lower case with
an underbar as a word separator. Properly naming everything makes it
much easier to read the code and get an idea of what it is doing. This
enables people new to this project to contribute easier.

All methods should have a comment that can be used by
[pydoc](https://docs.python.org/3/library/pydoc.html). The usage of
[pydoc][9]. The usage of
base classes is encouraged so functionality can be shared. Comments in
the code are encouraged when necessary to explain code that may not be
obvious, but avoid over commenting as well. Code should be able to be
read like a book, with descriptive names used, no fancy tricks unless
required. Always be concious of performance and security.

[1]: https://docs.google.com/presentation/d/1UrBG1X4MXwVd8Ps498FDlAYvesIailjjPPJfR_B4SUs/edit#slide=id.g15c1f409958_0_0 "slides"
[2]: https://github.com/orgs/hotosm/projects/22 "Our latest task board"
[3]: https://github.com/hotosm/fmtm/issues "issue queue"
[4]: https://github.com/hotosm/fmtm/labels "label categories"
[5]: https://help.github.com/articles/about-pull-requests/ "About Pull Requests"
[6]: https://www.markdownguide.org/ "Markdown format"
[7]: https://pytest.org/ "Pytest"
[8]: https://en.wikipedia.org/wiki/Camel_case "CamelCase"
[9]: https://docs.python.org/3/library/pydoc.html "pydoc"
66 changes: 46 additions & 20 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,21 @@

It is recommended to run FMTM on a Linux-based machine.

> This includes MacOS, but some [tools must be
> substituted](#alternative-operating-systems).
> This includes MacOS, but some [tools must be substituted][1].
>
> For Windows users, the easiest option is to use [Windows Subsystem for
> Linux](#alternative-operating-systems)
> For Windows users, the easiest option is to use [Windows Subsystem for Linux][2]
Before you can install and use this application, you will need to have
the following software installed and configured on your system:

> If running Debian/Ubuntu, the install script below does this for you.
[Git](https://git-scm.com/) to clone the FMTM repository.
[Git][3] to clone the FMTM repository.

[Docker](https://docs.docker.com/engine/install/)
[Docker][4]
to run FMTM inside containers.

[Docker Compose](https://docs.docker.com/compose/install)
[Docker Compose][5]
for easy orchestration of the FMTM services.

> This is Docker Compose V2, the official Docker CLI plugin.
Expand All @@ -45,16 +43,31 @@ bash install.sh
## Manual Install

If more details are required, check out the
[dev docs](https://hotosm.github.io/fmtm/dev/Setup/)
[dev docs][6]

### Table of Contents

1. [Clone the FMTM repository](#clone-the-fmtm-repository)
2. [Development: Setup Your Local Environment](#setup-your-local-environment)
3. [Start the API with Docker](#start-the-api-with-docker)
4. [Setup ODK Central User (Optional)](#setup-odk-central-user-optional)
5. [Import Test Data (Optional)](#import-test-data-optional)
6. [Check Authentication (Optional)](#check-authentication-optional)
- [Installation](#installation)
- [Software Requirements](#software-requirements)
- [Easy Install](#easy-install)
- [Manual Install](#manual-install)
- [Table of Contents](#table-of-contents)
- [Clone the FMTM repository](#clone-the-fmtm-repository)
- [Setup Your Local Environment](#setup-your-local-environment)
- [1. Setup OSM OAUTH 2.0](#1-setup-osm-oauth-20)
- [2. Create an `.env` File](#2-create-an-env-file)
- [Start the API with Docker](#start-the-api-with-docker)
- [Select the install type](#select-the-install-type)
- [Pull the Images](#pull-the-images)
- [Build the Frontend](#build-the-frontend)
- [Start the Containers](#start-the-containers)
- [Setup ODK Central User (Optional)](#setup-odk-central-user-optional)
- [Import Test Data (Optional)](#import-test-data-optional)
- [Check Authentication (Optional)](#check-authentication-optional)
- [Alternative Operating Systems](#alternative-operating-systems)
- [Windows](#windows)
- [MacOS](#macos)
- [A Note on Docker Desktop](#a-note-on-docker-desktop)

### Clone the FMTM repository

Expand All @@ -77,7 +90,7 @@ The FMTM uses OAUTH2 with OSM to authenticate users.

To properly configure your FMTM project, you will need to create keys for OSM.

1. [Login to OSM](https://www.openstreetmap.org/login)
1. [Login to OSM][28]
(_If you do not have an account yet, click the signup
button at the top navigation bar to create one_).
Click the drop down arrow on the top right of the navigation bar
Expand All @@ -90,7 +103,7 @@ To properly configure your FMTM project, you will need to create keys for OSM.
> Note: `127.0.0.1` is required for debugging instead of `localhost`
> due to OSM restrictions.
![image](https://user-images.githubusercontent.com/36752999/216319298-1444a62f-ba6b-4439-bb4f-2075fdf03291.png)
![image][29]

3. Only the _read user preferences permission_ is required as of now.

Expand Down Expand Up @@ -237,13 +250,13 @@ Windows Subsystem for Linux (WSL) can be used to run Docker.
This will run a Linux machine inside Windows very efficiently.

To install follow the
[official instructions](https://learn.microsoft.com/en-us/windows/wsl/install).
[official instructions][30].

Then continue with the FMTM [installation](#software-requirements).
Then continue with the FMTM [installation][31].

### MacOS

[Colima](https://github.com/abiosoft/colima) is recommended
[Colima][32] is recommended
to run `docker` and `docker compose` commands.

Install colima, docker, docker compose using brew:
Expand All @@ -267,7 +280,7 @@ Run Colima:
colima start
```

Then continue with the FMTM [installation](#software-requirements).
Then continue with the FMTM [installation][33].

> Note: only tagged backend images are multi-architecture, supporting
> MacOS. The regular images for fast continuous deployment are not:
Expand All @@ -289,3 +302,16 @@ runs docker commands inside a Linux virtual machine underneath.
It is often easier and more flexible to do this yourself.
Plus it gives you access to all other other tools available
in a Linux operating system!

[1]: #alternative-operating-systems "tools must be substituted"
[2]: #alternative-operating-systems "Windows Subsystem for Linux"
[3]: https://git-scm.com/ "Git"
[4]: https://docs.docker.com/engine/install/ "Docker"
[5]: https://docs.docker.com/compose/install "Docker Compose"
[6]: https://hotosm.github.io/fmtm/dev/Setup/ "dev docs"
[28]: https://www.openstreetmap.org/login "Login to OSM"
[29]: https://user-images.githubusercontent.com/36752999/216319298-1444a62f-ba6b-4439-bb4f-2075fdf03291.png "image"
[30]: https://learn.microsoft.com/en-us/windows/wsl/install "official instructions"
[31]: #software-requirements "installation"
[32]: https://github.com/abiosoft/colima "Colima"
[33]: #software-requirements "installation"
60 changes: 60 additions & 0 deletions contrib/scripts/docs/reformat_md_links_as_ref.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import re

this_file_in_docs = "User-Manual-For-Project-Managers.md"


def reformat_links_as_refs(file_name: str) -> None:
"""
Function takes in a mark down file, searches for inline links and changes them to reference (footnote) version.
NB the path to "docs" is hardcoded.
NB: Care should be taken to make sure that inline url links are formatted correctly (broken lines, spaces, parenthesis, etc.)
function created by contributor @cordovez.
"""
pattern = r"\[([^\]]+)\]\(([^)]+)\)"

# Read the original markdown document
with open(f"./docs/{this_file_in_docs}", "r") as file:
lines = file.readlines()

# Create a list to store the footnotes
footnotes = []

# Create a new list to store the modified lines
modified_lines = []

# Iterate through each line in the document
for line in lines:
# Find all matches of the pattern in the line
matches = re.findall(pattern, line)

# Iterate through the matches in reverse order
for match in reversed(matches):
label = match[0]
url = match[1]

# Generate the footnote reference
footnote_ref = f"[{label}][{len(footnotes) + 1}]"

# Replace the original hyperlink with the footnote reference
line = line.replace(f"[{label}]({url})", footnote_ref)

# Append the footnote to the list
footnotes.append(f'[{len(footnotes) + 1}]: {url} "{label}"')

# Append the modified line to the new list
modified_lines.append(line)

# Write the modified lines to the new document
with open(f"./docs/{this_file_in_docs}", "w") as file:
file.writelines(modified_lines)

# Append the footnotes to the end of the document
with open(f"./docs/{this_file_in_docs}", "a") as file:
file.write("\n\n")
file.write("\n".join(footnotes))


if __name__ == "__main__":
reformat_links_as_refs(this_file_in_docs)
Loading

0 comments on commit 512b130

Please sign in to comment.