diff --git a/.travis.yml b/.travis.yml index 6c6791eb0cc..40b4d4a28d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,8 @@ 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) @@ -19,7 +20,10 @@ script: | # 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: diff --git a/chore/check-links-in-doc.py b/chore/check-links-in-doc.py new file mode 100644 index 00000000000..29c6cc855db --- /dev/null +++ b/chore/check-links-in-doc.py @@ -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") diff --git a/doc/_release/Release.md b/doc/_release/Release.md index 01ef12aa3b6..bbfbafbb4a3 100644 --- a/doc/_release/Release.md +++ b/doc/_release/Release.md @@ -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` @@ -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. @@ -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 diff --git a/doc/about.md b/doc/about.md index b06109d81b9..fc71f55bd7e 100644 --- a/doc/about.md +++ b/doc/about.md @@ -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 }}) \ No newline at end of file +![Small powered logo]({{ "/images/spoonpowered.jpg" | prepend: site.baseurl }}) diff --git a/doc/command_line.md b/doc/command_line.md index fe0ffaf7ad4..cedc8aba886 100644 --- a/doc/command_line.md +++ b/doc/command_line.md @@ -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. diff --git a/doc/comments.md b/doc/comments.md index 3f71076ebcb..aff0a38fb2d 100644 --- a/doc/comments.md +++ b/doc/comments.md @@ -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. @@ -91,4 +91,4 @@ public class CtCommentProcessor extends AbstractProcessor { // process the ctComment } } -``` \ No newline at end of file +``` diff --git a/doc/doc_homepage.md b/doc/doc_homepage.md index 84292002d07..5b613ecaf98 100755 --- a/doc/doc_homepage.md +++ b/doc/doc_homepage.md @@ -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: {{ site.email }} -* 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 @@ -96,7 +96,7 @@ Snapshot version: ``` -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 diff --git a/doc/first_analysis_processor.md b/doc/first_analysis_processor.md index 784f30bef11..d106e9a82b5 100644 --- a/doc/first_analysis_processor.md +++ b/doc/first_analysis_processor.md @@ -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 this page. +You can view the complete meta model of Spoon at this page. It is a simple way to know what you can inspect with processors. {{site.data.alerts.end}} @@ -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}} \ No newline at end of file +{{site.data.alerts.end}}