Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

chore(website): add a link checker #872

Merged
merged 1 commit into from
Oct 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ jdk:
install:
- # download deps with maven
- mvn dependency:resolve

- pip install --user CommonMark requests

script: |
# Verify includes checkstyle, license and animal sniffer.
# site includes javadoc check (eg incorrect links)
mvn verify site -DskipTests &&
# the core of continuous integration
mvn test jacoco:report &&
# now coverage, but not failing
mvn coveralls:report -Pcoveralls --fail-never
mvn coveralls:report -Pcoveralls --fail-never &&
# documentation
python chore/check-links-in-doc.py


cache:
directories:
Expand Down
49 changes: 49 additions & 0 deletions chore/check-links-in-doc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/python
# checks the links of the Spoon documentation
# a problem is reported as an exception, hence as a Unic return code != -1, hence as a build failure

import CommonMark
import glob
import os
import codecs
import requests

URLS = []

def check_external_url(url):
# only checking the local or github files
# we may comment since later and check everything but it takes time
if "spoon.forge" not in url and "INRIA/spoon" not in url : return

if url in URLS: return
r = requests.get(url, headers = {"user-agent": "Mozilla/5.0 FakeBrowser"}) # sf.net, elsevier use stupid UA detection
if r.status_code != 200:
raise Exception(url+" invalid "+str(r.status_code))
URLS.append(url)


def main(where):
parser = CommonMark.Parser()

for root, subdirs, files in os.walk(where):
for i in files:
filename = root + '/' + i
if not filename.endswith('.md'): continue

ast = parser.parse(codecs.open(filename, encoding="utf8").read())
for i,_ in ast.walker():

if i.__dict__['t'] == "link":
url = i.__dict__['destination']
if url.startswith('http'): check_external_url(url)
# local file
elif not url.startswith('/'):
raise Exception("a link to a local page must start with / "+url+ " in "+filename)
else:
linked_page = where + '/' + url.replace(".html",".md")
if not os.path.exists(linked_page): raise Exception("no such page "+linked_page)

def debug(filename):
print "\n".join(str(x) for x in list(CommonMark.Parser().parse(codecs.open(filename, encoding="utf8").read()).walker()))

main("./doc")
10 changes: 3 additions & 7 deletions doc/_release/Release.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# How to release Spoon?

This article is a short summary of the [official documentation of sonatype][ossrh-guide], an [article](yegor) by yegor and [official documentation of maven release plugin](maven-release-plugin).
This article is a short summary of the [official documentation of sonatype](http://central.sonatype.org/pages/ossrh-guide.html), an [article by yegor](http://www.yegor256.com/2014/08/19/how-to-release-to-maven-central.html) and [official documentation of maven release plugin](http://maven.apache.org/maven-release/maven-release-plugin/).

## Main Workflow
1. open an account on `https://gforge.inria.fr`, add an SSH key there, check that you are a member of project `spoon`
1. check that gpg2, keepass are installed
1. take the latest commit of master (`git pull` on master)
1. get the GPG credentials of Spoon (on [partage.inria.fr](https://partage.inria.fr/alfresco/webdav/Sites/spirals/documentLibrary/security/), in `Spirals Team >> Document Library >> security >> keepass.kdbx`)
1. get the GPG credentials of Spoon (on `davs://partage.inria.fr/alfresco/webdav/Sites/spirals/documentLibrary/security/`, in `Spirals Team >> Document Library >> security >> keepass.kdbx`)
1. download the keepass file
1. import the keys with `gpg2 --import` (doc in keypass.kdbx)
1. check with `gpg2 --list-keys`
Expand Down Expand Up @@ -93,7 +93,7 @@ After that, you can update your `settings.xml` of your Maven:

## Initialize the project

All steps in this sections are details in the [official documentation][apache-maven] and modify `pom.xml` of the project.
All steps in this section are detailed in the [official documentation](http://central.sonatype.org/pages/apache-maven.html) and modify `pom.xml` of the project.

1. Specify sonatype plugin and distributions managements for release and snapshot (if necessary).
3. Specify GPG plugin to verify and sign your project.
Expand All @@ -102,7 +102,3 @@ All steps in this sections are details in the [official documentation][apache-ma
6. Specify a scm about your Sonatype repository.


[ossrh-guide]: http://central.sonatype.org/pages/ossrh-guide.html
[yegor]: http://www.yegor256.com/2014/08/19/how-to-release-to-maven-central.html
[maven-release-plugin]: http://maven.apache.org/maven-release/maven-release-plugin/
[apache-maven]: http://central.sonatype.org/pages/apache-maven.html
4 changes: 2 additions & 2 deletions doc/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ And special thanks for original spooners:

![Spooners]({{ "/images/spoonTeam.jpg" | prepend: site.baseurl }})

Spoon was originally created by [Renaud Pawlak](https://www.linkedin.com/pub/renaud-pawlak/6/ba8/b8a) (aka Master Yoda), [Nicolas Petitprez](https://www.linkedin.com/pub/nicolas-petitprez/32/26/8a4/en) (aka Little Padawan), and [Carlos Noguera](https://www.linkedin.com/pub/carlos-noguera/11/86a/383) (aka Luke Spoonwalker) in 2005-2006.
Spoon was originally created by Renaud Pawlak (aka Master Yoda), Nicolas Petitprez (aka Little Padawan), and Carlos Noguera (aka Luke Spoonwalker) in 2005-2006.

## Logos

![Big logo]({{ "/images/spoon.jpg" | prepend: site.baseurl }})
![Big powered logo]({{ "/images/spoonpowered_big.jpg" | prepend: site.baseurl }})
![Small powered logo]({{ "/images/spoonpowered.jpg" | prepend: site.baseurl }})
![Small powered logo]({{ "/images/spoonpowered.jpg" | prepend: site.baseurl }})
2 changes: 1 addition & 1 deletion doc/command_line.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The basic usage of Spoon consists in defining the original source location and t
$ java -classpath /path/to/binary/of/your/processor.jar:spoon-core-4.2.0-jar-with-dependencies.jar spoon.Launcher -i /path/to/src/of/your/project -p fr.inria.gforge.spoon.processors.CatchProcessor
```

If you plan to repeatedly run Spoon from the command line, it may be a good idea to combine all of your commands into a single bash script. An example of this can be found [here](https://github.com/INRIA/spoon/blob/master/docs/example_scripts/example_usage_script.sh).
If you plan to repeatedly run Spoon from the command line, it may be a good idea to combine all of your commands into a single bash script. An example of this can be found [here](https://github.com/INRIA/spoon/blob/master/doc/example_scripts/example_usage_script.sh).

Note that when you use Spoon in command line, you manually handle the classpath.
In particular, if the to-be-transformed source files depend on libraries, specify them with the `--source-classpath` flag.
Expand Down
4 changes: 2 additions & 2 deletions doc/comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ In Spoon there are four different kinds of comments:
* Block comments (from /* to */) `CtComment.CommentType.BLOCK`
* Javadoc comments (from /** to */) `CtComment.CommentType.JAVADOC`

The comments are represented in Spoon with a `CtComment` class ([javadoc](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/declaration/CtComment.html)).
The comments are represented in Spoon with a `CtComment` class ([javadoc](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtComment.html)).
This class exposes API to get the content of the comment `CtComment.getContent()`, the type of the comment `CtComment.getCommentType()` and the position `CtComment.getPosition()`.

We also try to understand to which element they are attached.
Expand Down Expand Up @@ -91,4 +91,4 @@ public class CtCommentProcessor extends AbstractProcessor<CtComment> {
// process the ctComment
}
}
```
```
4 changes: 2 additions & 2 deletions doc/doc_homepage.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ You have different options:

* Open an issue on [Github](https://github.com/INRIA/spoon/issues) (preferred).
* Send an email to the mailing list: <a href="mailto:{{ site.email }}">{{ site.email }}</a>
* Post a question to [StackOverflow with tag inria-spoon](stackoverflow.com/tags/inria-spoon)
* Post a question to [StackOverflow with tag inria-spoon](http://stackoverflow.com/tags/inria-spoon)

## News

Expand Down Expand Up @@ -96,7 +96,7 @@ Snapshot version:
</repositories>
```

To know more about the usage of Spoon, you can read the documentation in the ["Usage" section](http://spoon.gforge.inria.fr/command_line.html#).
To know more about the usage of Spoon, you can read the documentation in the ["Usage" section](/command_line.html).

## Contributing

Expand Down
4 changes: 2 additions & 2 deletions doc/first_analysis_processor.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This super class takes a generic type parameter to know what type you want inspe
For this tutorial, we inspect a catch, a `CtCatch` ([javadoc](http://spoon.gforge.inria.fr/mvnsites/spoon-core/apidocs/spoon/reflect/code/CtCatch.html)).

{{site.data.alerts.note}}
You can view the complete meta model of Spoon at <a href="http://spoon.gforge.inria.fr/diagrams.html">this page</a>.
You can view the complete meta model of Spoon at <a href="diagrams.html">this page</a>.
It is a simple way to know what you can inspect with processors.
{{site.data.alerts.end}}

Expand Down Expand Up @@ -89,4 +89,4 @@ $ java -classpath /path/to/binary/of/your/processor.jar:spoon-core-{{site.spoon_
1. Specify all dependencies in your classpath. If your processor has dependencies, don't forget to package your processor.jar with all dependencies!
2. Specify spoon in the classpath because we use spoon concepts in our processor.
3. Specify your processors in fully qualified name.
{{site.data.alerts.end}}
{{site.data.alerts.end}}